Note that there are some explanatory texts on larger screens.

plurals
  1. POa javascript code for returning a radio box value
    primarykey
    data
    text
    <p>I have a ajax table that I want to mark one of the rows in the table with radio box on the left , problem is that I'm not good at javascript , I want to get the radio box value by id from this table when it has marked , actually this ajax table shows info's from database by using while loop and an array . can anybody write a code for getting or returning informations of a selected row by radio box with javascript .</p> <p>this is my ajax table :</p> <pre><code>&lt;?php session_start(); ?&gt; &lt;?php $connection = mysql_connect('localhost', '', ''); $db = mysql_select_db('students', $connection); mysql_query("SET CHARACTER SET utf8;"); mysql_query("SET SESSION collation_connection = 'utf8_persian_ci'"); $term = strip_tags(substr($_POST['searchit'],0, 100)); $term = mysql_escape_string($term); // Attack Prevention if($term=="") echo " .enter a usernumber"; else{ $query = mysql_query("select * from test where username like '{$term}%'", $connection); $string = ''; echo "&lt;br&gt;"; echo "&lt;center&gt;"; echo "&lt;div&gt;"; echo "&lt;div align='center' width = 900&gt;"; echo "&lt;table class='styled-table' cellspacing='0' width='900' border='1'&gt;"; echo "&lt;tr&gt;"; echo "&lt;th width='10' scope='col'&gt;Check&lt;/th&gt;"; echo "&lt;th width='10' scope='col'&gt;Username&lt;/th&gt;"; echo "&lt;th width='10' scope='col'&gt;Password&lt;/th&gt;"; echo "&lt;th width='10' scope='col'&gt;Name&lt;/th&gt;"; echo "&lt;th width='10' scope='col'&gt;Last Name&lt;/th&gt;"; echo "&lt;th width='10' scope='col'&gt;Midterm&lt;/th&gt;"; echo "&lt;th width='10' scope='col'&gt;Class Mark&lt;/th&gt;"; echo "&lt;th width='10' scope='col'&gt;Final&lt;/th&gt;"; echo "&lt;th width='10' scope='col'&gt;State&lt;/th&gt;"; echo "&lt;th width='10' scope='col'&gt;Level&lt;/th&gt;"; echo "&lt;th width='10' scope='col'&gt;Teacher&lt;/th&gt;"; echo "&lt;th width='10' scope='col'&gt;Class Num&lt;/th&gt;"; echo "&lt;th width='10' scope='col'&gt;Receipt&lt;/th&gt;"; echo "&lt;th width='10' scope='col'&gt;Date&lt;/th&gt;"; echo "&lt;/tr&gt;"; if (mysql_num_rows($query)){ while($row = mysql_fetch_assoc($query)){ echo "&lt;tr&gt;"; echo "&lt;td align='center'&gt;&lt;input class='styled-input' type='checkbox' name='check' id='check' value= " . $row['check'] ." &gt;&lt;/td&gt;"; echo "&lt;td align='center'&gt;&lt;input class='styled-input' type='text' name='user' id='user' value= " . $row['username'] ." &gt;&lt;/td&gt;"; echo "&lt;td align='center'&gt;&lt;input class='styled-input' type='text' name='pass' id='pass' value= " . $row['password'] ." &gt;&lt;/td&gt;"; ?&gt; &lt;td align='center'&gt;&lt;input class='styled-input' type='text' name='name' id='name' value= "&lt;? echo $row['name']; ?&gt;" &gt;&lt;/td&gt; &lt;td align='center'&gt;&lt;input class='styled-input' type='text' name='lastname' id='lastname' value= "&lt;? echo $row['lastname']; ?&gt;" &gt;&lt;/td&gt; &lt;td align='center'&gt;&lt;input class='styled-input' type='text' name='midmark' id='midmark' value= "&lt;? echo $row['midmark']; ?&gt;" &gt;&lt;/td&gt; &lt;td align='center'&gt;&lt;input class='styled-input' type='text' name='classmark' id='classmark' value= "&lt;? echo $row['classmark']; ?&gt;" &gt;&lt;/td&gt; &lt;td align='center'&gt;&lt;input class='styled-input' type='text' name='finalmark' id='finalmark' value= "&lt;? echo $row['finalmark']; ?&gt;"&gt;&lt;/td&gt; &lt;td align='center'&gt;&lt;input class='styled-input' type='text' name='state' id='state' value= "&lt;? echo $row['state']; ?&gt;" &gt;&lt;/td&gt; &lt;td align='center'&gt;&lt;input class='styled-input' type='text' name='level' id='level' value= "&lt;? echo $row['level']; ?&gt;" &gt;&lt;/td&gt; &lt;td align='center'&gt;&lt;input class='styled-input' type='text' name='teacher' id='teacher' value= "&lt;? echo $row['teacher']; ?&gt;" &gt;&lt;/td&gt; &lt;?php echo "&lt;td align='center'&gt;&lt;input class='styled-input' type='text' name='classnum' id='classnum' value= " . $row['classnum'] ." &gt;&lt;/td&gt;"; echo "&lt;td align='center'&gt;&lt;input class='styled-input' type='text' name='receipt' id='receipt' value= " . $row['receipt'] ." &gt;&lt;/td&gt;"; echo "&lt;td align='center'&gt;&lt;input class='styled-input' type='text' name='date' id='date' value= " . $row['date'] ." &gt;&lt;/td&gt;"; echo "&lt;/tr&gt;"; $_SESSION["suser"]=$row['username'] ; if(($row['check'])==true) {$_SESSION["sreceipt"]=$row['receipt'] ;} } echo "&lt;/table&gt;"; echo "&lt;/div&gt;"; echo "&lt;/div&gt;"; echo "&lt;/center&gt;"; }else{ $string = "nothing found !"; $_SESSION["suser"]=''; $_SESSION["sreceipt"]=''; } echo $string; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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