Jump to content

Determine contents of listbox


qwerty234

Recommended Posts

How can I determine the values of a listbox, both unselected or selected after submitting the form:

 

                        <select name="sel1" size="10" multiple="multiple">
                        <?  PHP code populates listbox ?>
                        </select>

 

Do I have to use Javascript to determine the contents, like in the pseudo code Javscript below. But how would you pass the Javascript return value to PHP?

 

function listBoxContents(sel1)
{
  var selLength1 = sel1.length;
  var valuesPresent1 = new Array(sel1.length-1);
  var i;
  for(i=0; i<=selLength1-1; i++)
  {
        valuesPresent1[i]=sel1.options[i].valueOf();
  }

return valuesPresent1;
}

Link to comment
https://forums.phpfreaks.com/topic/49753-determine-contents-of-listbox/
Share on other sites

You could try putting the results in a hidden field (using javascript) then submit the form? You might have problems with an array there so if I were you i'd concatenate the values of the select box (using somthing like |) then explode the results on the PHP page.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.