-1

I made a HTML page which has to work in local. So no server, PHP or anything !

I've found a IP Calculator Script and try to get back the query parameter values that I've created on a form.

A wonderful way could be to have the direct answer in a onClick action... but is it possible ?

Currently, I'm at this point :

function show_alert() {
  alert("Test");
}
<form name="form" action="others.html">
  <!-- bla bla, with the table and so on -->
  <input type="image" src="../images/go.png" onclick="show_alert();">

Currently, i've the alert but i lost the $get ...or i have the $get but i lost the alert ^^ Could you help me ?

mplungjan
  • 169,008
  • 28
  • 173
  • 236
snow
  • 9
  • 1
    Do you mean [query string arguments](https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript)? (I think that's called [$_GET](https://www.php.net/manual/en/reserved.variables.get.php) in PHP.) – Rup Apr 26 '19 at 11:52
  • 1
    What do you mean by `$Get`? From where you are getting this? Please add the complete code so someone can help you out – Sami Ahmed Siddiqui Apr 26 '19 at 11:52
  • You need to show an [mcve] which demonstrates the problem. Don't just show us working code. – Quentin Apr 26 '19 at 12:02
  • The
    send a GET and then, i've my url with : autres.html?csubnet=30&cip=138.190.133.6&type=ipv4 i need to get these information back..
    – snow Apr 26 '19 at 12:02

1 Answers1

1

You want this if you do not want to leave the page

window.addEventListener("load",function() {
  document.getElementById("form").addEventListener("submit",function(e) {
    e.preventDefault(); // stop submit
    console.log(this.cip.value,this.subnet.value,this.type.value)
  });
});
<form id="form">  
  IP: <input type="text" name="cip" value="" />
  Subnet: <input type="text" name="subnet" value="" />
  Version: <select name="type">
    <option value="ipv4">ipv4</option>
    <option value="ipv6">ipv6</option>
  </select>
  <button type="submit">GO <img src="../images/go.png" /></button>
</form>

OR this in the second page:

window.addEventListener("load",function() {
  var parms = new URLSearchParams(location.search)
  console.log(parms.get("cip"),parms.get("type"),parms.get("subnet"))
});
mplungjan
  • 169,008
  • 28
  • 173
  • 236