Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP RadioButton Submit form
    primarykey
    data
    text
    <p>I have been creating a website to allow users to rate an image uploaded by another user. I have my code working great. The user is presented with the image, a button to flag the image, 10 radio buttons to choose their rating and a submit button (all within the same form).</p> <p>My problem is that I would like to remove the submit button and process the form when the user clicks the radio button. The problem with this is that the flag button (image button) is also submitting the form. My code is below:</p> <p><strong>HTML</strong></p> <pre><code>&lt;form name="ratebox" action="Box.php?bid=&lt;?php echo $boxId ?&gt;" method="post"&gt; &lt;table style="margin: 0 auto;"&gt; &lt;tr&gt; &lt;td colspan="2"&gt;&lt;img src="img/boxes/&lt;?php echo $boxId ?&gt;.png" title="&lt;?php echo $boxName ?&gt;" height="350" width="350"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;input type="image" name="flag_submit" src="img/Flag.png" onmouseover="this.src='img/Flag_Click.png'" onmouseout="this.src='img/Flag.png'" height="30" width="30" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2" style="text-align:center;"&gt; 1&lt;input type="radio" name="rdoRate" value="1" &gt; 2&lt;input type="radio" name="rdoRate" value="2" &gt; 3&lt;input type="radio" name="rdoRate" value="3" &gt; 4&lt;input type="radio" name="rdoRate" value="4" &gt; 5&lt;input type="radio" name="rdoRate" value="5" &gt; 6&lt;input type="radio" name="rdoRate" value="6" &gt; 7&lt;input type="radio" name="rdoRate" value="7" &gt; 8&lt;input type="radio" name="rdoRate" value="8" &gt; 9&lt;input type="radio" name="rdoRate" value="9" &gt; 10&lt;input type="radio" name="rdoRate" value="10" &gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;td colspan='4' align='center'&gt;&lt;input type='submit' name='rate_submit' value='Rate'&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p><strong>PHP</strong></p> <pre><code>if (isset($_POST['flag_submit_x'])) { //Code to process the flagged image } if (!empty($_POST['rate_submit'])) { //Code to process the rated image } </code></pre> <p>Is there any way I can submit the form when a radio button is pressed and retrieve the value of the radio button that has been pressed?</p>
    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