[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

How to reference values in text boxes and input fields in current form, to pass to next form AND how to submit the current form

I have an html page where a user is completing a form.  At the end of the form, I would like to have an option where they can click a link, and it will both save (submit) the current form, but then also send them to the same form again, but with carrying over a few of the fields that they have already filled in.  I'm unclear how to reference the contents of the fields.

So, for example, I have a textbox field for first name, named "fname".  How would I reference the contents of that field to pass it over in a url link:

<a href="https://somedomain.com/form.php?fname="value of whatever they typed into the fname form">Add Another</a>

When they click the link above to "Add Another", I also want to submit the contents of the current form so that it is saved.

I'm not sure if this can be done in just html, or with javascript, or with some other language altogether.  Any suggestions are appreciated.

  • 2
2 Solutions
<a href="javascript:void(0)" onclick="location.href = 'https://somedomain.com/form.php?fname=' + document.getElementsByName('fname')[0].value ">Add Another</a>
with : <input name="fname" />

or :

<a href="javascript:void(0)" onclick="location.href = 'https://somedomain.com/form.php?fname=' + document.getElementById('fname').value ">Add Another</a>
with : <input name="fname" id="fname" />
another one : <a href="javascript:void(0)" onclick="location.href = 'https://somedomain.com/form.php?fname=' + encodeURIComponent(document.getElementsByName('fname')[0].value) ">Add Another</a>
sah18Author Commented:
This is very helpful... do you also know how I can *first* submit the current form, then forward the user to syntax you have above to show them the form again, but with a few fields carried over?  I need to save what they've done on the current form, then direct them to the (partially) filled form again to continue completing.

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now