...

View Full Version : Need help passing form data



Jhorra
01-09-2007, 01:37 AM
Here is my problem:
I have two select boxes, one that populates from the database, when you select an item from the first and click add, it adds it to the second select. Now, because none of them are actually selected in the second box they aren't passed on the post.

My attempted solution:
When someone adds or removes an item in the function I added this:


var selected_songs = document.getElementById("selected_songs");
var hdn_songs = document.getElementById("hdn_selected_songs");
for(var i = 0;i< selected_songs.length; i++)
{
hdn_songs.value = hdn_songs.value + "," + album_songs.options[i].value;
}


Which I had hoped would happen is that when a song was added it would loop through the select box and place each value into my hidden input.

Here is my input field and select box if it helps


<input type="hidden" name="hdn_selected_songs" id="hdn_selected_songs" />

<select size="10" multiple="multiple" name="selected_songs[]" id="selected_songs">
</select>


Edit: I don't get any errors in the javascript console in Firefox, so it must be in my logic somewhere.
Any suggestions? Let me know if I need to post additional code.

Thanks

Jhorra
01-09-2007, 06:19 AM
Ok, turns out the browser wasn't reloading the js file. Once I placed the code in the header it ran like it was supposed to.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum