scottstown Posted June 29, 2008 Share Posted June 29, 2008 Hey, I am building a 5 star rating system. I am trying to pass the variable of the star when that star is clicked and then pass it to a php processing page... Start of the form... , Currently, I get the hidden field to pass fine, but not the "vote" variable. <form name="myform" action="vote.php" method='POST'> <input type="hidden" name="id" value="<? echo $postid; ?>"> Submit part... <ul class="rating onestar"> <li class="one"><a href="javascript:document.myform.submit()" name="vote" value="1" title="1 Star">1</a></li> <li class="two"><a href="javascript:document.myform.submit()" name="vote" value="2" title="2 Stars">2</a></li> <li class="three"><a href="javascript:document.myform.submit()" name="vote" value="3" title="3 Stars">3</a></li> <li class="four"><a href="javascript:document.myform.submit()" name="vote" value="4" title="4 Stars">4</a></li> <li class="five"><a href="javascript:document.myform.submit()" name="vote" value="5" title="5 Stars">5</a></li> </ul> Thanks for any help, Scott Link to comment https://forums.phpfreaks.com/topic/112475-pass-variable-on-form-submit/ Share on other sites More sharing options...
thatsgreat2345 Posted June 29, 2008 Share Posted June 29, 2008 A link isn't an input type and there for is not passed a long despite you giving it a name and value. You will need to use a form element such as you ahve done for id. Link to comment https://forums.phpfreaks.com/topic/112475-pass-variable-on-form-submit/#findComment-577492 Share on other sites More sharing options...
br0ken Posted June 29, 2008 Share Posted June 29, 2008 This might work... <input type="image" src="images/path/star.jpg" name="star" value="1"> <input type="image" src="images/path/star.jpg" name="star" value="2"> <input type="image" src="images/path/star.jpg" name="star" value="3"> <input type="image" src="images/path/star.jpg" name="star" value="4"> <input type="image" src="images/path/star.jpg" name="star" value="5"> Link to comment https://forums.phpfreaks.com/topic/112475-pass-variable-on-form-submit/#findComment-577497 Share on other sites More sharing options...
scottstown Posted June 29, 2008 Author Share Posted June 29, 2008 lol ... thank you very much!! wow, I was just not thinking... so here is what I did and it worked fine.... I completely took out the form... and just did this.... <li class="one"><a href="vote.php?id=<? echo $postid; ?>&&vote=<? echo "1"; ?>" title="1 Star">1</a></li> Thanks again!! Scott Link to comment https://forums.phpfreaks.com/topic/112475-pass-variable-on-form-submit/#findComment-577500 Share on other sites More sharing options...
thatsgreat2345 Posted June 29, 2008 Share Posted June 29, 2008 lol ... thank you very much!! wow, I was just not thinking... so here is what I did and it worked fine.... I completely took out the form... and just did this.... <li class="one"><a href="vote.php?id=<? echo $postid; ?>&&vote=<? echo "1"; ?>" title="1 Star">1</a></li> Thanks again!! Scott Wouldn't recommend this. This could really cause a problem with people voting like thousands of times and exploiting your voting system, that is if it really matters Plus you have two & should only be one. Link to comment https://forums.phpfreaks.com/topic/112475-pass-variable-on-form-submit/#findComment-577502 Share on other sites More sharing options...
scottstown Posted June 29, 2008 Author Share Posted June 29, 2008 @thatsgreat2345, yes your right about only 1 & sign. As for the allowing people to vote a lot of times, I am storing the usernames of thoes who have already voted in my sql, thanks Scott Link to comment https://forums.phpfreaks.com/topic/112475-pass-variable-on-form-submit/#findComment-577546 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.