/    Sign up×
Community /Pin to ProfileBookmark

Need help passing form data

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:

[code]
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;
}
[/code]

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

[code]
<input type=”hidden” name=”hdn_selected_songs” id=”hdn_selected_songs” />

<select size=”10″ multiple=”multiple” name=”selected_songs[]” id=”selected_songs”>
</select>
[/code]

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

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@JhorraauthorJan 09.2007 — Ok, for whatever reason my browser wouldn't reload the js file, even after clearing the cache. Once I put the code into the header it all worked.
×

Success!

Help @Jhorra spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...