0
echo "<fieldset data-role='controlgroup'>

                <input type='radio' name='radio-choice-1' id='radio-choice-1'
                    **value='$val' onclick='hello($s)'**/> <label


                    for='radio-choice-1'>$val</label>

How can I pass $s as a string like 'sdd' to a javascript function in the html page. I an mot able to do this. It is creating some errors in mis position of quotes. Help me out.

tcooc
  • 20,629
  • 3
  • 39
  • 57

1 Answers1

1

Try switching to using single quotes versus double quotes. What is the difference between single-quoted and double-quoted strings in PHP?

echo '<fieldset data-role="controlgroup">
    <input type="radio" name="radio-choice-1" id="radio-choice-1" **value="' . $val . '" onclick="hello($s)"**/>
    <label for="radio-choice-1">"' . $val . '"</label>';

Single quotes treat most things 'as-is' double quotes try to interpret, turning $s into the value of the variable $s. *Note the concatenation around your actual variables.

Community
  • 1
  • 1
CLo
  • 3,650
  • 3
  • 26
  • 44