Jump to content

List box Selected Value


notonurnelly

Recommended Posts

HI all,

I have a list box that has the permanent numbers 0 - 9. I simply want to maintain the selected value once the form is submitted. I plan to have a test on the form that looks for fields that are not completed.

The listbox at the moment is produced using an if statement. If the variable is not set the list box produces 0-9 and is fine.

If the form has been submitted and a variable is sent to the listbox. It manages to show the correct selected value, but when the list box is expanded again that value is repeated 10 times instead of having 0 - 9 the value (say 3) is repeated in the list box.

Here is my code hope someone can help.

Many Thanks
Jamie

    print "<SELECT NAME=Q1a value=0>";
  for ($i=0; $i<10; $i++){
if (isset ($Q1a))
{
print "<OPTION value =$i selected>$Q1a</OPTION>";
  }
    else
    {
        print "<OPTION value=$i>$i</OPTION>";
    }
  }

  print "</SELECT><br><br>";
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.