manipulating radio box selection with javascript

Posted by Crays on Stack Overflow See other posts from Stack Overflow or by Crays
Published on 2010-05-16T12:18:39Z Indexed on 2010/05/16 12:20 UTC
Read the original article Hit count: 150

Filed under:
|

Hi guys, i'm trying to do a poll but i designed it without any radio box in it. So i decided to make the selection being highlighted with a different background color, all is done with jquery.

I set the display of the radio box to none so that it wouldn't show, gave each a unique ID. Here's the script.

<form action="v_poll.php" method="post">
<ul class="voting">
<li class="voting votetext"><input type="radio" name="voting" value="a1" style="display:none;" id="a1"><a onClick="vote('a1')"Answer 1</a></li>
<li class="voting votetext"><input type="radio" name="voting" value="a2" style="display:none;" id="a2"><a onClick="vote('a2')">Answer 2</a></li>
<li class="voting votetext"><input type="radio" name="voting" value="a3" style="display:none;" id="a3"><a onClick="vote('a3')">Answer 3</a></li>
<input type="hidden" value="1" name="id" />
<input type="submit" value="submit">
</ul>
</form>
<script type="text/javascript">
function vote(TheValue) {
GetElementById(TheValue).checked=true;
}
</script>

But when i checked the value of the radio box with $_POST['voting'], it is blank. Not the value assigned to the radio box. Anything i'm doing wrong?

Please help. Thanks.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about php