2021年3月3日星期三

How to change the value when I type ?variable=value at url?

Situation:

  1. The input value is empty and the type is hidden.
  2. I type ?hiddenname=007 at url
  3. I click the button"submit" and cause function call()..

Expect:

  1. The system fills in the value into the input according to ?hiddenname=007 at url using function call()
  2. after that, the system send the form with value 007 to the server.

Current result:

  1. the system still send the form with empty value.

url

localhost/index.html?hiddenname=007  

index.html

<!DOCTYPE html>  <html>      <head>          <script>              function call(){                  document.forms["form1"].hiddenname.value=hiddenname;                      console.log("function run");                      }          </script>      </head>      <body>          <form name="form1" action="end.php">              <input type="hidden" id="hiddenid" name="hiddenname" value="" />                <input type="submit" id="send" onclick="call()"/>                        </form>      </body>  

end.php

<?php  echo $_GET['hiddenname'];  ?>  
https://stackoverflow.com/questions/66467421/how-to-change-the-value-when-i-type-variable-value-at-url March 04, 2021 at 09:45AM

没有评论:

发表评论