Alexander Vasilchuk Alexander Vasilchuk - 1 year ago 71
HTML Question

RadioButtons in php

I've got a form:

<form action= "catrand.php" method="POST" name="form">
<h4>How mach text need to print?</h4>
<input type="text" onkeyup="validate(this)" name="inp"> <script> function validate(inp) { inp.value = inp.value.replace(/[^\d,.]*/g, '') .replace(/([,.])[,.]+/g, '$1') .replace(/^[^\d]*(\d+([.,]\d{0,5})?).*$/g, '$1'); } </script>
<h4>Select how print text</h4>
<input type="radio" name="b001" value="First"><font>text</font>
<input type="radio" name="b001" value="Second"><font>check</font>
<input type="radio" name="b001" value="Last"><font>radio</font>
<h4>Input text</h4>
<input type="text" name="inp1">
<input type="text" name="inp2">
<input type="text" name="inp3">
<p><input type="submit"></p>

and php code:

switch($_POST['b001']) {
case "Last":
echo "<input type=\"radio\" onclick=\"uncheck_radio(this)\" value=\"First\" \"name=\"h001\">" .$numberone;
echo "<input type=\"radio\" onclick=\"uncheck_radio(this)\" value=\"Second\" \"name=\"h001\">".$numbertwo;
echo "<input type=\"radio\" onclick=\"uncheck_radio(this)\" value=\"Third\" \"name=\"h001\">".$numberthree."</br>";


But despite the fact that the names of radiobuttons are same, i can mark two and more radiobuttons. Why? What is wrong in my code?

Answer Source

You dont need the escaped quotes here: \"name= try with just name=

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download