Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Senior Member
    Join Date
    Mar 2002
    Location
    Alabama sans the damn flag
    Posts
    263
    Member #
    38
    I have a select object with 3 options. I want to preselect one of the 3 depending on the value of DataVal


    ...selected='" & DataVal & "' .... doesn't work in HTML.


    Suggestions?
    DerFarm
    I talk to squirrels.
    Squirrels Answer.

  2.  

  3. #2
    Senior Member
    Join Date
    Mar 2002
    Location
    Alabama sans the damn flag
    Posts
    263
    Member #
    38
    I got it. Turns out you have to build the select statement in a string and put " selected" behind the value statement in the option block

    Code:
                 SexBox="<tr><th>Sex:</th><td><select name='SexBox'>"
                 SexBox = SexBox & "<option value='M'"
                 if DataVal="M" then
                    SexBox = SexBox & " selected"
                 end if
                 SexBox=SexBox & ">Male</Option><Option value='F'"
                 if DataVal="F" then
                    SexBox=SexBox & " selected"
                 end if
                 SexBox=SexBox & ">Female</Option><Option value='U'"
                 if DataVal="U" then
                    SexBox=SexBox & " selected"
                 end if
                 SexBox=SexBox & ">Unk</Option></select></td>"
    DerFarm
    I talk to squirrels.
    Squirrels Answer.

  4. #3
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    I recently had a related problem. It's the only solution but an annoying one
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  5. #4
    Senior Member
    Join Date
    Mar 2002
    Location
    Alabama sans the damn flag
    Posts
    263
    Member #
    38
    Well, it's not really as bad as it looks. I wrote a function to retrieve pieces of delimited strings. The actual code now looks like:


    Code:
    SexBox = Retrieve(SexBox,DataVal,1) & DataVal & " selected" & retrieve(SexBox,DataVal,2)
    where SexBox is the string of the box template, DataVal is the String delimiter (with a leading ') and the number is the part of the string that is returned.

    Works well
    DerFarm
    I talk to squirrels.
    Squirrels Answer.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:32 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com