Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2011
    Location
    Wisconsin
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Problems with HTML/JavaScript variables

    I cant figure out how to get the value of a name inputed in HTML into the following script...

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)">
    <meta name="created" content="Sat, 10 Sep 2011 19:40:31 GMT">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <title>Enter golfers name</title>
    <!--[if IE]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <SCRIPT LANGUAGE="JavaScript" type="text/javascript" src="script1.js"></SCRIPT>
    <SCRIPT LANGUAGE="JavaScript">

    function GetPage(){
    document.write("OK")
    <!-- var fullname = "david park"
    var lab = "";
    var result = fullname.toUpperCase();
    var word=result.split(" ");
    fname = word[0]
    lname = word[1]
    alpha = lname.slice(0,1);
    lab = fname.concat("_")
    lab = lab.concat(lname)
    if(word[2]){
    ext = word[2]
    lab = lab.concat("_")
    lab = lab.concat(ext)
    }
    var intro = "./Stats_";
    page = intro.concat(alpha);
    page = page.concat("_golfers.html#");
    page = page.concat(lab)
    document.write(page)

    <!-- window.location.pathname = page
    }
    </script>
    </head>
    <body>
    <center>
    <form action="form_action.asp" method="get">
    You can enter the golfersname or select him from the above list.<br><br>
    <input type="text" name="fullname" />
    <button type="submit" onclick="GetPage()">GO</button>



    </form>
    </center>
    <BR><BR><BR>
    This is the end
    </body>
    </html>

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,918
    Thanks
    56
    Thanked 545 Times in 542 Posts
    the "usual" way is

    Code:
    html:
    <input type="text" id="name"></input>
    
    js:
    var fullname=document.getElementById("name").value;


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •