Note that there are some explanatory texts on larger screens.

plurals
  1. POdisable and enable onclick event not working for multiple rows
    primarykey
    data
    text
    <p>I am working on a php project,</p> <p>well, i need help like i have 10 records to update data to database see the diag below-</p> <p><img src="https://i.stack.imgur.com/cE9HK.png" alt="enter image description here"></p> <p>now like you see No_Info option , says : No_Data and Available.</p> <p>So when user click for No_data for ID:1 , it disable fields that are attached to corresponding id. and same available works.</p> <p>But it only all working for ID: 1 , for no other row its working.....</p> <p>EDIT: Update code here.</p> <pre><code>&gt;&gt;&gt;&gt; &lt;?php //connect to the database server $objConnect = mysql_connect("localhost","root","") or die(mysql_error()); //select the database $objDB = mysql_select_db("main_project"); //select which data you want to get. $sql = "SELECT * FROM website_maindb"; $objQuery = mysql_query($sql); // $Ct = mysql_query('select * from company_type'); /* $objResult = mysql_fetch_array($objQuery); // Not to use when using loop to call full database */ ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt; &lt;title&gt;ss&lt;/title&gt; &lt;script&gt; function disable() { document.getElementById("noi1").disabled=true; document.getElementById("noi2").disabled=true; document.getElementById("noi3").disabled=true; document.getElementById("noi4").disabled=true; document.getElementById("noi5").disabled=true; document.getElementById("noi6").disabled=true; } function enable() { document.getElementById("noi1").disabled=false; document.getElementById("noi2").disabled=false; document.getElementById("noi3").disabled=false; document.getElementById("noi4").disabled=false; document.getElementById("noi5").disabled=false; document.getElementById("noi6").disabled=false; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form" action="insert.php" method="post"&gt; &lt;table width="700" border="1"&gt; &lt;tr&gt; &lt;th&gt;&lt;/th&gt; &lt;th width="20"&gt; &lt;div align="center"&gt;ID &lt;/div&gt;&lt;/th&gt; &lt;th width="98"&gt; &lt;div align="center"&gt;website &lt;/div&gt;&lt;/th&gt; &lt;th width="98"&gt; &lt;div align="center"&gt;category &lt;/div&gt;&lt;/th&gt; &lt;th width="98"&gt; &lt;div align="center"&gt;email &lt;/div&gt;&lt;/th&gt; &lt;th width="98"&gt; &lt;div align="center"&gt;contact form &lt;/div&gt;&lt;/th&gt; &lt;th width="98"&gt; &lt;div align="center"&gt;Primary No. &lt;/div&gt;&lt;/th&gt; &lt;th width="98"&gt; &lt;div align="center"&gt;Secondary No. &lt;/div&gt;&lt;/th&gt; &lt;th width="98"&gt; &lt;div align="center"&gt;fax &lt;/div&gt;&lt;/th&gt; &lt;th width="98"&gt; &lt;div align="center"&gt;Company type &lt;/div&gt;&lt;/th&gt; &lt;th width="98"&gt; &lt;div align="center"&gt;No_Info &lt;/div&gt;&lt;/th&gt; &lt;th width="98"&gt; &lt;div align="center"&gt;time &lt;/div&gt;&lt;/th&gt; &lt;/th&gt; &lt;/tr&gt; &lt;?php $options = ''; $Ctype=mysql_query("select distinct typec from company_type"); while($row = mysql_fetch_array($Ctype)) { $options .="&lt;option&gt;" . $row['typec'] . "&lt;/option&gt;"; } ?&gt; &lt;?php $i = 0; while($objResult = mysql_fetch_array($objQuery)) { $i++; ?&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="hidden" name="WID" value="&lt;?=$objResult["WID"];?&gt;"&gt;&lt;/td&gt; &lt;td&gt;&lt;label&gt;&lt;input type="text" name="ID" value="&lt;?=$objResult["WID"];?&gt;" disabled&gt;&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="website" value="&lt;?=$objResult["website"];?&gt;"&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="cat" size="10"&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" id="noi1" name="email" size="10"&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" id="noi2" name="cform" size="10"&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" id="noi3" name="contactp" size="10"&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" id="noi4" name="contacts" size="10"&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" id="noi5" name="fax" size="10"&gt;&lt;/td&gt; &lt;td&gt;&lt;select id="Ctype" name="Ctype"&gt; &lt;?=" $options "?&gt; &lt;/select&gt;&lt;/td&gt; &lt;td&gt;&lt;button type="button" onclick="disable()" size="20"&gt;No_Data&lt;/button&gt; &lt;/br&gt; &lt;button type="button" onclick="enable()" size="20"&gt;Available&lt;/button&gt; &lt;/td&gt; &lt;td&gt;&lt;input type="text" id="noi6" name="time" size="10"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php } ?&gt; &lt;button type="submit" id="send"&gt;Submit&lt;/button&gt; &lt;/form&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>can anyone help solving it..</p>
    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.
 

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