Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make the submit button also send an extra value

I have a long form with a submit button that sends the values of all the fields into the address bar.

However, I want the submit button to ALSO add an extra value (&submitted=yes) when it is clicked.

How can I convert my button:

<input type="submit" name="submitted" value="submit">

to do this?

The idea is that I could then use that value in javascript when the page loads along with the other fields:

<script language="javascript">  
var urlParams = new URLSearchParams(window.location.search);
var LastName = urlParams.get('LastName');
var Submitted = urlParams.get('Submitted');
like image 831
Sweepster Avatar asked Jul 25 '26 13:07

Sweepster


1 Answers

Easiest solution: add a hidden input field to your form.

<input type="hidden" name="submitted" value="yes">
like image 157
Robby Cornelissen Avatar answered Jul 27 '26 02:07

Robby Cornelissen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!