...

View Full Version : Problems with HTML/JavaScript variables



ronrumpf
09-13-2011, 05:23 AM
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>

xelawho
09-13-2011, 05:41 AM
the "usual" way is


html:
<input type="text" id="name"></input>

js:
var fullname=document.getElementById("name").value;



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum