Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.