Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/449.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将index1.htm中texbox ID的表单输入引用到index2.htm中的表中?_Javascript_Html_Css_Forms - Fatal编程技术网

Javascript 如何将index1.htm中texbox ID的表单输入引用到index2.htm中的表中?

Javascript 如何将index1.htm中texbox ID的表单输入引用到index2.htm中的表中?,javascript,html,css,forms,Javascript,Html,Css,Forms,我试图将用户在此索引中输入的URL显示到index.2中的表中。这是我的密码 index1.htm: <!DOCTYPE html> <html> <head> <script> function check_url(){ //Get input value var elem = document.getElementById("url_input"); var input_v

我试图将用户在此索引中输入的URL显示到
index.2
中的表中。这是我的密码

index1.htm:

<!DOCTYPE html>
<html>
  <head>
    <script>
      function check_url(){
        //Get input value
        var elem = document.getElementById("url_input");
        var input_value = elem.value;
        //Set input value to lower case so HTTP or HtTp become http
        input_value = input_value.toLowerCase();
        //Check if string starts with http:// or https://
        var regExr = /^(http:|https:)\/\/.*$/m; 
        Test; expression;
        var result = regExr.test(input_value);
        //If http:// or https:// is not present add http:// before user input
        if (!result){
          var new_value = "http://"+input_value;
          elem.value=new_value;
        }
      }
    </script>      
    <title>
        CS310: Assignment 3 #1
    </title>
  </head>
  <body>
    <h1><div align="center">What are your favorite websites on the internet?</div></h1><hr> 
    <div align="center">
      <p>Please enter websites in the proper URL format.</p>
      <p>Example: (http://www.myURL.com)</p>
      <form action="index2.htm">
        Website 1:<input type="url" size="25px" id="1" form="form1"    name="website_address1" placeholder="Enter a website address"><br>
        Website 2:<input type="url" size="25px" id="2" form="form2" name="website_address2" placeholder="Enter a website address"><br>
        Website 3:<input type="url" size="25px" id="3" form= "form3" name="website_address3" placeholder="Enter a website address"><br>
        <input type="submit" value="Create Table">
      </form>
    </div>
</html>

这看起来像是学校的作业。如果是这样的话,我建议你做一些研究,而不是让别人帮你做。我已经完成了大部分工作。我只需要帮助将两个索引链接在一起以显示正确的URL。我尝试用唯一的id名称定义每个输入,并在index2.htm中引用这些id。我为自己是个笨蛋而道歉!我对网络编程还不熟悉,并且已经在这个问题上纠缠了一段时间。您可以使用本地存储或服务器会话存储(提到两种明显的技术)来跨网页存储信息。
<!DOCTYPE html>
<html>
  <head>
    <title>
        CS310: Assignment 3 #1
    </title>
  </head>
  <body>
    <h1><div align="center">What are your favorite websites?</div></h1>
    <hr>  
    <div align= "center"><table border= "1" width = "40%"
         summary="This table lists the URLs inputted by the user.">  
      <caption><strong>Your favorite websites</strong></caption>
        <tr>
          <th><a href=target="1">Take me to Website #1</a></th>
        </tr>
        <tr>
          <th><a href="2">Take me to Website #2</a></th>  
        </tr>
        <tr>
          <th><a href="3">Take me to Website #3</a></th>  
        </tr>
      </table>
    </div>

  </body>
</html>