Jump to content

pass variable on form submit


scottstown

Recommended Posts

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

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">

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.