0

I am getting error with the following code

    $string.="<input class='jt-test-question-answer-choice-radio' name='q1' type='$input' value='q20a1' onclick=\"correct_answer1(\"$correctanswer\",'$row1[1]')\";/>";

$correctanswer is an array having value "test2,test4"; I have used implode function to split the array and then in the js function I have used split.When clicked the function is not calling.

4
  • Check your outputted HTML and you may find out: you're using double quote both on and in the onclick property. Commented Aug 7, 2013 at 10:08
  • Check the outputted HTML. Also, is $correctanswer an array or a string? Commented Aug 7, 2013 at 10:10
  • I am not able to check output as the page is an Ajax page.$correctanswer value is "test2,test4" ie I have used implode of array and I get the value like this to pass it in javascript function Commented Aug 7, 2013 at 10:15
  • To check output in chrome - after the input element is visible right click it and select 'Inspect element'. Then right click click the element in Developer tools and select 'Copy as HTML'. As for your problem, try changing onclick value to \"correct_answer1('$correctanswer','$row1[1]')\" Commented Aug 7, 2013 at 11:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.