0

I am trying to select option and redirect page with form action post method to get some information and get back to previous page with those input value after submit by javascript. Could anyone tell me how to do that?

this is my code in js:

var elements = document.getElementsByName("shipping_id")[0];
  elements.onchange = function(){
     if(this.selectedIndex == 1){
       var newWin = open('/test/static/src/html/test.htm','test','height=589,width=1004');

}; };

code in html:

<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <title>test</title>
  </head>
  <body>
  <form method="post" action="http://test.ashx">
  <input type="submit" value="submit" />
  </form>
  </body>
</html>

Thanks and looking forward to hear answers!!

HYC
  • 59
  • 1
  • 1
  • 7

2 Answers2

0

You can use localStorage or sessionStorage to save information and then pass it to another page.

Below is the link for localStorage and sessionStorage examples: http://www.w3schools.com/html/html5_webstorage.asp

Check this answer for reference: Send value from one page to another

Community
  • 1
  • 1
0

This is what AJAX was invented for. Not to worry, it's actually pretty simple.

The point of AJAX is that (from the first page) you send data to another file, that file does something with the data (e.g. a MySQL lookup, and create a formatted table with the data in it) and returns the result, which your code then displays back on the (first) page.

The best thing about AJAX is that it does all this behind the scenes, and the page does not change or refresh or flash. It looks professional...

Take a look at these examples to see how easy AJAX is.

A simple example

More complicated example

Populate dropdown 2 based on selection in dropdown 1


Using AJAX to make a Login system

Community
  • 1
  • 1
cssyphus
  • 31,599
  • 16
  • 79
  • 97