Note that there are some explanatory texts on larger screens.

plurals
  1. POPosting a submit button value
    primarykey
    data
    text
    <p>In a form i am making,i need to inform the processing php script what button was clicked.I have three buttons,new,save and delete.I was expecting the form and all the buttons values to be posted but the form + the button clicked only gets posted.I am looking at the html spec here <a href="http://www.w3.org/TR/html401/interact/forms.html#submit-format" rel="nofollow">http://www.w3.org/TR/html401/interact/forms.html#submit-format</a> but i am yet to find some explanation if this should be expected.I have this php script</p> <pre><code>&lt;?php /** tpost.php */ //Buttons $new = $_POST['new']; $save = $_POST['save']; $delete = $_POST['delete']; //Error: Notice: Undefined index: save in C:\wamp\www\form-dev\troll.php on line 7 //Forms $city = $_POST['city']; $zip = $_POST['zip']; $cs = $_POST['cs']; //Error: Notice: Undefined index: save in C:\wamp\www\form-dev\troll.php on line 8 //Buttons echo echo '&lt;b&gt;'.$new.'&lt;/b&gt;' .'&lt;br/&gt;'; echo '&lt;b&gt;'.$save.'&lt;/b&gt;' .'&lt;br/&gt;'; echo '&lt;b&gt;'.$delete.'&lt;/b&gt;' .'&lt;br/&gt;'; //Forms echo echo '&lt;b&gt;'.$city.'&lt;/b&gt;' .'&lt;br/&gt;'; echo '&lt;b&gt;'.$zip.'&lt;/b&gt;' .'&lt;br/&gt;'; echo '&lt;b&gt;'.$cs.'&lt;/b&gt;' .'&lt;br/&gt;'; ?&gt; </code></pre> <p>this is the html i am using</p> <pre><code>&lt;!Doctype html&gt; &lt;head&gt; &lt;meta charset="uft-8"&gt; &lt;title&gt;Buttons post&lt;/title&gt; &lt;script type="text/javascript" src="jquery-1.7.2.min.js"&gt;&lt;/script&gt; &lt;style type="text/css"&gt; label{ width:15%; float:left; font-style:italic; } &lt;/style&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $('.inew').on("click",function() { alert('new'); }); $('.isave').on("click",function() { alert('save'); }); $('.idelete').on("click",function() { alert('delete'); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="tpost.php" name="troll" method="post"&gt; &lt;label&gt;Enter Your City&lt;/label&gt;&lt;input type="text" name="city" value="some-city"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt; &lt;label&gt;Enter Your Neighbourhood&lt;/label&gt;&lt;input type="text" name="zip" value="my-zip" /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt; &lt;label&gt;Enter Your Nearest Shopping Mall&lt;/label&gt;&lt;input type="text" name="cs" value="shop-here" /&gt;&lt;br/&gt; &lt;br/&gt;&lt;hr/&gt;&lt;br/&gt; &lt;br/&gt; &lt;hr/&gt; &lt;input class="inew" type="submit" name="new" value="new" /&gt; &lt;input class="isave" type="submit" name="save" value="save" /&gt; &lt;input class="idelete" type="submit" name="delete" value="delete" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>What is the explanation for this?.</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.
    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