[thelist] Javascript: problem writing parsed URL variable to form text box
Bruso, John
jbruso at SHERIDAN.EDU
Tue Oct 4 16:59:12 CDT 2005
I have this login form that I want to be able to feed a variable to via
the URL.
For example:
http://dev.sheridan.edu/uportal/login/index.htm?uP_fname=eservices-outlo
ok
So far I've managed to parse the URL and even write the variable to
the page, but I'm pulling my hair out trying to figure out how to
write that variable inside of a text box.
Here's my code so far:
<html>
<head>
<SCRIPT src="index_files/link-parser.js" type=text/javascript> </SCRIPT>
<script type="text/javascript">
function setInput()
{
document.forms[0].uPfname.value = url["uP_fname"};
}
window.onload=setInput;
</script>
</head>
<body>
<FORM id=formMyVTLogon name=myForm onsubmit=doLogonWait()
action=http://www-dev.sheridan.edu:8080/uPortal/Login method=post>
<script>
document.write("<input type=\"text\" name=\"uP_fname\"
value='"+uP_fname+"' />");
</script>
<input type="text" name="uP_fname" />
</form>
</html>
Link-parser.js:
var qs = location.search.substring(1);
var nv = qs.split('&');
var url = new Object();
for(i = 0; i < nv.length; i++)
{
eq = nv[i].indexOf('=');
url[nv[i].substring(0,eq).toLowerCase()] =
unescape(nv[i].substring(eq + 1));
}
More information about the thelist
mailing list