print "<Font face=\"calibri, Arial\"><table id=\"rnatable\" border=2px width=100%>";
print "<th></th>";
print "<th>a</th>";
print "<th>b</th>";
print "<th>c</th>";
print "<th>d</th>";
print "<th>e</th>";
print "<th>f</th>";
print "<th>g</th>";
while($array = mysql_fetch_array($sql_query))
{
$id=$array['a'];
print "<tr id=\"newtr\">";
print "<td><input id=\"check\" type=\"checkbox\" name=\"keyword[]\" value=\"$id\" ></td>";
print "<td>".$array['a']."</td>";
print "<td>".$array['b']."</td>";
print "<td>".$array['c']."</td>";
print "<td>".$array['d']."</td>";
print "<td>".$array['e']."</td>";
print "<td>".$array['f']."</td>";
print "<td>
<a href=\"http://localhost/rnasearch/retrieve.php?a=$id\">bla</a>
</td></tr></font>";
}
print "</table>";
}
this is part of a php searchengine script that i wrote to retrieve data from a database and as you can see the last column that is g contains a link which when clicked takes the user to the second php script which retrieves additional information of that entry, but this is done for only single entries so as you can see i introduced checkboxes so that the user can check any number of checkboxes and retrieve information as per their wish
now to do this i created a
<div id="floatMenu">
<ul class="menu1">
<center><li><form name="senddata" method="POST" action="http://localhost/retrieve.php" style="display:inline;"><input id="fasta" type="text" class="multitext"><input name="Fasta" type="Submit" value="Retrieve Fasta"></form>
this is a css floating menu….so far so good….everything went fine….
after this i had to write a javascript to do this and i’ve been stuck there searching forums for the last 4 days!
this is the javascript i found from somewhere which came close to doing wht i wanted it to do
window.onload = function () {
var cb = document.getElementById('check');
var fasta = document.getElementById('fasta');
cb.onclick = function () {fasta.value = cb.value + ",";
};};
this script only sends the value of the first checkbox in the table, the others are not found by it, mind you its not the first checkbox selected its the first checkbox that is present in the table
how can i resolve this problem so that even if i have n number of checkboxes in my table, if the user chooses to do so they can retrieve n number of information….please help i’ve almost lost hope in this!
IDs are meant to be unique in one HTML Document. So you can’t use them to retrieve many of them with the same Id. You may have to modify your PHP and JS like this:
And
You can find a jsFiddle here: http://jsfiddle.net/ZfmNw/1/