0

i have a simple form with a gender drop down and a temperature dropdown and i want them to go to the next page and just simple be outputted to the screen. I think i may have to change my save button as well. must use javascript with i could use php lol

  <div class="form-group">
   <label for="sel1">Gender:</label>
   <select class="form-control" id="gender">
      <option>Male</option>
      <option>Female</option>
   </select>
</div>

<div class="form-group">
   <label for="sel1">Temperature (Degrees):</label>
   <select class="form-control" id="gender">
      <option>Fahrenheit</option>
      <option>Celcius</option>
   </select>
</div> 

<div style="text-align: center;"><a href="index.html" class="btn btn-info btn-lg"> Save Settings</a></div>
bigdowg
  • 379
  • 3
  • 5
  • 19

2 Answers2

1

I think that you can use local storage for this:

   localStorage.setItem('showInTheNextPage', $('.form-group').html());

Then, in the next page:

   var fromPrevPage = localStorage.getItem('showInTheNextPage');
   $('.form-group').html(fromPrevPage);

UPDATE : Illustration

https://stackoverflow.com/a/16264547/1845408

Page 1: http://jsfiddle.net/Xotic750/dfqsK/

Page 2: http://jsfiddle.net/Xotic750/ayvPq/

Community
  • 1
  • 1
renakre
  • 8,001
  • 5
  • 46
  • 99
0

may be you do not need to pass to the "next" page? may be you need to reload rest (or some part of the page in background), namely use ajax?

{your form html here}
<a href="index.html" class="btn btn-info btn-lg" onclick="reload"> Save Settings</a>
<div id="content"></div>
<script >
  function reload(evt) {
    var body = $('form#some-form').serializeArray();
    var xhr = $.post(window.location.origin+'/api'+window.location.pathname, body )
      .done(function(data) {
        console.log( "success" );
        $('#content').html(data);
      })
      .fail(function() {
        console.log( "error" );
    });
  }
</script>

assuming use of JQuery.

skazska
  • 421
  • 2
  • 8