Page 1 of 1
Get values from a select that aren't selected on a post?
Posted: Mon Jan 08, 2007 6:55 pm
by Jhorra
I have two select boxes, and using javascript you select an item from one, and move it to the other. Then I want all the options in the second select box on the post. However, since they aren't selected, they don't post. Anyone have a suggestion on what I can do? I tried to put an on click event on the submit button that would loop through and select them all, but it didn't seem to work. Any other ideas? Maybe I could place a hidden element and add the values to it?
Posted: Mon Jan 08, 2007 7:31 pm
by volka
Wrong forum ->
Client Side
You can set an onsubmit handler for the second form and set the select attribute to true for all options there.
Posted: Mon Jan 08, 2007 7:56 pm
by Jhorra
volka wrote:Wrong forum ->
Client Side
You can set an onsubmit handler for the second form and set the select attribute to true for all options there.
Can you move this post for me?
Also, I did try something like you said, and put an onclick event on my submit button then used this for the function is calls
Code: Select all
var selected_songs = document.getElementById("selected_songs");
for(var i = 0;i< selected_songs.length; i++)
{
selected_songs.options[i].selected = true;
}
But that didn't seem to do it.
Posted: Mon Jan 08, 2007 8:55 pm
by volka
Either use a javascript debugger or add some (annoying) debug output like
Code: Select all
var selected_songs = document.getElementById("selected_songs");
alert(selected_songs);
for(var i = 0;i< selected_songs.length; i++)
{
alert(i);
selected_songs.options[i].selected = true;
}
return true;
Jhorra wrote:Can you move this post for me?
No, but it's likely a moderator will do so sooner or later
