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

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


0
sah18
Asked:
sah18
  • 2
2 Solutions
 
leakim971PluritechnicianCommented:
<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" />
0
 
leakim971PluritechnicianCommented:
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>
0
 
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.
0

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