Hi guys, I have been struggling away for a fair few hours so have turned to you guys for help.. Essentially I have a voting script that when the user selects their star rating it saves their vote in a hidden html input and then gets submitted when the user submits the form.. here is the link I am using on the 1star as an example: <a href="javascript:void(0)" onclick="avote(1,pr_'.$ids.'); return false;" class="one-star">1</a>  Code (markup): As there are many items being reviewed I need to pass a variable for the name of the hidden field? They are pr_0, pr_1 etc. The first part is the rating the second is the  name of the hidden id. However when I click it nothing appears to happen. I am not sure how to assign the value to my hidden input box. Here is my current attempt at the functions: function avote(score, id) { document.reviews.pr_+id.value = score; } Code (markup): All help much appreciated!
does it work in all browsers? im not saying it doesnt just usually i use longer version like document.forms["reviews"].elements["pr_"+id].value
"reviews" is the form name and "pr_"+id is the input name, so the "forms" and "elements" are not needed ["reviews"] is the same as .reviews You could even use it in jQuery if you wanted. $('element')["html"]("hi");
i know that but as far as i remember i had problems with this shorter version in some old browsers, so just in case it is good to know longer version too ;-)
document.forms["form_name"].elements["field_name"].value is the best way to do it, especially you are calling a number of elements.. you can also use document.getElementsByName