0

I am developing an application using HTML and JQuery (no PHP) and i have two pages, index.html and register.html. At the first page (index.html) you are asked to enter a card number, then click submit. When the user does this i move to the second page where i have a hidden input.

This is the code, index.html

<form id="RegisterForm" method="post" data-ajax="false" id="registerCardForm" action="register.html"> 
        <input type="text" id="cardNumberRegField" type="tel"  name="cardNumber" class="required number register" minlength="16" maxlength="16" /> 
        <input name="Submit" type="submit" class="button" value="Register"/>
    </form>

register.html

<input  id="tfscCardNumber" type="hidden" name="tfscCardNumber" class="readonly" minlength="2" maxlength="20" readonly="readonly" disabled="disabled"/>

So my question how do I load the number in the first page to the hidden input in the second page before the page is fully loaded?

newSpringer
  • 1,018
  • 10
  • 28
  • 44

5 Answers5

0

You don't. Posts are handled strictly server side. Once the information is processed by the server, the html is rendered and the page is pushed out. If you change your method to get, then the url would have all of the variables of the form and you could use jQuery to parse it out.

Joel Etherton
  • 37,325
  • 10
  • 89
  • 104
0

May be you can set method attribute for form to "get" so params will be in URL, and then on register.html you can parse document.location for that params.

Hope it helps.

Alexey Ogarkov
  • 2,916
  • 23
  • 28
0

Without server side scripting, the only way to do it would be in the url, or with a cookie. Keep in mind that the data is fully exposed then, and easily manipulated. Not to mention that, with the data in the url, it will leave a trace in the browser history.

When doing things like this, seriously considering to server side scripting.

Joeri Hendrickx
  • 16,947
  • 4
  • 41
  • 53
0

Perhaps it would be simpler to use one single web page instead of two?

Put the contents of each of your current pages into divs on a single page. On page load, only show the first div. When the user clicks, hide the first div and show the second div.

You can keep the user's input in a hidden input.

DOK
  • 32,337
  • 7
  • 60
  • 92
0

I would use cookie for that, with jquery cookie plugin. https://github.com/carhartl/jquery-cookie

On Submit, store in cookie, on load, use cookie !

befox
  • 206
  • 2
  • 4