Note that there are some explanatory texts on larger screens.

plurals
  1. POhow can i clear may table data if i click my reset button which resets my radio buttons on different forms
    primarykey
    data
    text
    <p>what i want is if i click my reset button, it resets my radio buttons and clears its value on may table data.... what should i add to my codes here...</p> <pre><code>function clear(){ var elems = document.getElementsByName('president') &amp;&amp; document.getElementById('president'); for(i=0;i&lt;elems.length;i++) elems[i].checked=false; document.list.editform.president.value=''; } </code></pre> <p>lets say for instance the <code>document.getElementsByName('president')</code> is for my reset button which is on my editform and the <code>document.getElementById('president')</code> is for my table data which is on the other form. should it be possible that if i click the reset, two forms would be called on my function? plss help...</p> <p>this is my select_candidate.php</p> <pre><code>&lt;script type="text/javascript"&gt; &lt;!-- function clear(){ var elems = document.getElementsByName('president'); for(i=0;i&lt;elems.length;i++) elems[i].checked=false; document.list.editform.president.value=''; } function get_president_value() { for (var i=0; i &lt; document.list.president.length; i++) { if (document.list.president[i].checked) { return document.getElementById('president').innerHTML = document.list.president[i].value; } } } --&gt; &lt;/script&gt; &lt;form method="post" name="list"&gt; &lt;div id="TabbedPanels1" class="TabbedPanels" &gt; &lt;ul class="TabbedPanelsTabGroup"&gt; &lt;li class="TabbedPanelsTab" tabindex="0"&gt;President&lt;/li&gt; &lt;/ul&gt; &lt;div class="TabbedPanelsContentGroup"&gt; &lt;div class="TabbedPanelsContent"&gt; &lt;fieldset&gt; &lt;legend&gt;President&lt;/legend&gt; &lt;?php require_once('candidate/president.php'); ?&gt; &lt;/fieldset&gt;&lt;/div&gt; &lt;/form&gt; &lt;!-- here the value of my radio button will appear on this table data and this is where i want to clear as i click my reset button which clears also my radio buttons... --&gt; &lt;div&gt; &lt;fieldset&gt; &lt;legend&gt;List of Your Candidates&lt;/legend&gt; &lt;table&gt; &lt;tr&gt;&lt;td&gt;President: &lt;/td&gt; &lt;td id="president" onclick="clear()"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/fieldset&gt; &lt;/div&gt; </code></pre> <p>and heres my president.php</p> <pre><code> &lt;?php // get the records from the database if ($result = $mysqli-&gt;query("SELECT * FROM candidate_info WHERE position= 'president'")) { // display records if there are records to display if ($result-&gt;num_rows &gt; 0) { // display records in a table echo "&lt;table border='1' cellpadding='10'&gt;"; // set table headers echo "&lt;tr&gt;&lt;th&gt;Student ID&lt;/td&gt;&lt;th&gt;Course&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;/tr&gt;"; while ($row = $result-&gt;fetch_object()) { // set up a row for each record echo "&lt;tr&gt;"; echo "&lt;td&gt;" . $row-&gt;studid . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row-&gt;course . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row-&gt;fname . " ". $row-&gt;mname ." ". $row-&gt;lname ." &lt;/td&gt;"; echo "&lt;td&gt;&lt;input type ='radio' name='president' id='". $row-&gt;studid ."' value='" . $row-&gt;fname . " ". $row-&gt;mname ." ". $row-&gt;lname ."' onchange='get_president_value()' &gt;&lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; } // if there are no records in the database, display an alert message else { echo "No results to display!"; } } // show an error if there is an issue with the database query else { echo "Error: " . $mysqli-&gt;error; } // close database connection $mysqli-&gt;close(); // &lt;a href="records.php"&gt;Add New Record&lt;/a&gt; ?&gt; //here is my reset button that resets my radio buttons &lt;form name="editform" method="post"&gt; &lt;input type="reset" name="reset" value="Clear" id="candidate2" onClick="clear()"&gt; &lt;/form&gt;&lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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