<input type="button" name="Next" id="Next" value="Next" onclick="showNextQuest(<?php echo $_POST  ['$qtnid']; ?>)" />

$qtnid is the name of a radio button, i used the post method to know which one among the radio buttons is selected. The radio button has the same name with different values.It return an undefined error when itried to use alert function inside the showNextQuest function in the javascript. plz help me out.

share|improve this question
feedback

2 Answers

<input type="button" name="Next" id="Next" value="Next" onclick="showNextQuest(<?php echo $_POST  ['$qtnid']; ?>)" />

should be

<input type="button" name="Next" id="Next" value="Next" onclick="showNextQuest('<?php echo $_POST  ['$qtnid']; ?>')" />

To make it a string, not a varname

share|improve this answer
feedback

If the values are strings you should also put single quotes around your PHP if you want to pass the value as a string:

showNextQuest('<?php echo $_POST['$qtnid']; ?>')
share|improve this answer
not as a string but as a variable, integer variable – Teejaygenius Jan 5 at 15:53
@Teejaygenius In that case the error most likely occurs with the $ n the name: w3.org/TR/html4/types.html#type-cdata – ascii-lime Jan 5 at 17:07
@Teejaygenius """ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").""", so starting a name with $ is invalid markup and undefined behaviour, which means your $_POST might not fill correctly with it. You can check your $_POST for $qtnid with print_r($_POST) – ascii-lime Jan 5 at 17:09
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.