Jump to content

Form won't submit


orgzchaos

Recommended Posts

<?php

if (isset($_POST['checking'])) { echo $_POST['checking']; }
if (isset($_POST['test'])) { echo $_POST['test']; }

?>


<form id="testform2" action="testform.php" method="post">

<select name="checking" onchange="this.form.submit()"><option value="5">5</option><option value="6">6</option></select>
<input type="text" name"test" id="test">
<a href="#" onclick="this.form.submit()">submit it!</a>
</form>

 

It works when I try to submit by selecting a new value from the dropdown box but when I try to click the link it won't display the text field value. That is a test case for a problem I m having in one of my codes.

Link to comment
https://forums.phpfreaks.com/topic/257761-form-wont-submit/
Share on other sites

That is not the problem, I just made a mistake while making a test case for the forums. Code on the actual file is fine and still not working. I just tried the following code and no results:

 

<?php

if (isset($_POST['checking'])) { echo $_POST['checking']; }
if (isset($_POST['test'])) { echo $_POST['test']; }

?>


<form id="testform2" action="testform.php" method="post">

<select name="checking" onchange="this.form.submit()"><option value="5">5</option><option value="6">6</option></select>
<input type="text" name="test" id="test">
<a href="#" onclick="this.form.submit()">submit it!</a>
</form>

Link to comment
https://forums.phpfreaks.com/topic/257761-form-wont-submit/#findComment-1321170
Share on other sites

How about

<a href="#" onclick="testform2.submit()">submit it!</a>

 

I would also add a blank selection so you can select "5".

<select name="checking" onchange="this.form.submit()">
<option value="">-</option>
<option value="5">5</option>
<option value="6">6</option>
</select>

Link to comment
https://forums.phpfreaks.com/topic/257761-form-wont-submit/#findComment-1321185
Share on other sites

Worked. Is there any way to differentiate between the two submits on the server side? i.e. the receiving ( or action ) php script knows how the form was submitted i.e. either through the onchange or onclick?

 

I know it is unlikely but still it may be useful if there was some way.

Link to comment
https://forums.phpfreaks.com/topic/257761-form-wont-submit/#findComment-1321197
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.