Note that there are some explanatory texts on larger screens.

plurals
  1. POfill text fetched from database into text fiels on selection of radio buttons
    text
    copied!<p>I am fetching data from database , for each of row data fetched I am creating a radio button against the row. The details of a land-sites are fetched here.</p> <p>I have a form for booking these land sites, which takes land-site details and name and email of user.</p> <p>So when a user selects a radio button, the details of land-site should be automatically filled in the form, How to achieve this.</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;?php $phase=$_GET["q"]; $sql ="select id, phase,size, facing, sply, status from plot where status='avail' and phase='$phase'"; $ret=mysql_query($sql, $connect); echo "&lt;form&gt;"; echo"&lt;div style='overflow-y:scroll;height:200px;float:left;' &gt;&lt;table border=1 &gt; &lt;tr&gt; &lt;td&gt;select &lt;/td&gt;&lt;td&gt;phase&lt;/td&gt; &lt;td&gt;site no.&lt;/td&gt; &lt;td&gt;plot-size&lt;/td&gt; &lt;td&gt;face&lt;/td&gt; &lt;td&gt;sply&lt;/td&gt; &lt;td&gt;status&lt;/td&gt; &lt;/tr&gt;" ; while($row = mysql_fetch_array($ret, MYSQL_ASSOC)) { echo "&lt;tr&gt;". "&lt;td&gt;&lt;input type='radio' name='book' value='book' onClick=\"whichForm('send_to_one');\" /&gt;&lt;/td&gt;". "&lt;td&gt;{$row['phase']} &lt;/td&gt;". "&lt;td&gt;{$row['id']} &lt;/td&gt;". "&lt;td&gt; {$row['size']} &lt;/td&gt;". "&lt;td&gt; {$row['facing']} &lt;/td&gt;". "&lt;td&gt;{$row['sply']} &lt;/td&gt; ". "&lt;td&gt;{$row['status']} &lt;/td&gt; ". "&lt;/tr&gt;"; } echo "&lt;/table&gt;&lt;/div&gt;"; mysql_close($connect); ?&gt; &lt;div id="send_to_one" style="float:right;padding:30px"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;Name :&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="name" value=""/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Mobile:&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="mobile" value="" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Email :&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="email" value="" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Phase : &lt;/td&gt; &lt;td&gt;&lt;select name="phase" id="phase"&gt; &lt;option value="1"&gt;1&lt;/option&gt; &lt;option value="2"&gt;2&lt;/option&gt; &lt;option value="3"&gt;3&lt;/option&gt; &lt;option value="4"&gt;4&lt;/option&gt; &lt;/select&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Site :&lt;/td&gt; &lt;td&gt; &lt;input type="text" name="site" value="" id="site" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;!-- &lt;tr&gt;&lt;td&gt;&lt;span id="status"&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; --&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="radio" name="status" value="blocked" class="radioBtn" onclick="advance.disabled=true" /&gt; block&lt;/td&gt; &lt;td&gt;&lt;input type="radio" name="status" value="booked" class="radioBtn" onclick="advance.disabled=false" /&gt; book &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Advance paid &lt;/td&gt; &lt;td&gt;&lt;input type="text" name="advance" value="" id="textField" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;input type="submit" value="submit" /&gt;&lt;/td&gt; &lt;td&gt; &lt;input type="reset" value="clear all" /&gt; &lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;?php echo "&lt;/form&gt;"; ?&gt; &lt;/div&gt; &lt;!-- div ends here --&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload