如何从index2.htm中将texbox id中的表单输入引用到index2.htm中的表中?

时间:2015-05-28 22:29:50

标签: javascript html css forms

我正在尝试将用户在此索引中输入的网址显示在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>

这是显示的表格。该表应显示用户输入textboxesindex1.htm的三个网址。

index2.htm:

<!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>

0 个答案:

没有答案