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

Posted on 2011-11-01
Last Modified: 2012-05-12
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=""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.

Question by:sah18
    LVL 81

    Accepted Solution

    <a href="javascript:void(0)" onclick="location.href = '' + document.getElementsByName('fname')[0].value ">Add Another</a>
    with : <input name="fname" />

    or :

    <a href="javascript:void(0)" onclick="location.href = '' + document.getElementById('fname').value ">Add Another</a>
    with : <input name="fname" id="fname" />
    LVL 81

    Assisted Solution

    another one : <a href="javascript:void(0)" onclick="location.href = '' + encodeURIComponent(document.getElementsByName('fname')[0].value) ">Add Another</a>
    LVL 9

    Author Comment

    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

    Javascript: Crash Course

    Javascript is not only emerging as the most important language to know, it's flexibility is unique. With Javascript being deployed on the web, mobile and even the desktop this is the one language that all technologists need to know.

    Join & Write a Comment

    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
    The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now