In article <op**************@news.butschek.com>,
Holger Butschek <ho****@butschek.com> wrote:
I have designed a html-form
and am trying to path parameters with the suffix of i.e.
?Seminartitel=hallowelt in the url.
.... Now, I would like to preset the field Seminar of the form with the value
Seminartitel.
Try invoking with formfillin.html?Seminartitel=pass
file: formfillin.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Form</title>
<SCRIPT type="text/javascript">
/*
Most folks lower case the first word in the name of
functions and variables.
Using an upper case letter
in the first word is reserved for functions which
initialize class members:
var myCar = new Car("VW");
Anyway, be consistant.
*/
function getUrlValue(entry)
{
/* Without the var, you are declaring this
variable a global variable. */
var urlText=location.search;
var fc=urlText.slice(0,1);
if (fc=="?")
{
var l=urlText.length;
urlText=urlText.slice(1,l);
var argSet=urlText.split("&");
for (var i=0;i<argSet.length;i++)
{
var as=argSet[i].split("=");
if (as[0]==entry)
{
return (as[1]);
}
}
}
/*
Moved null return in case nothing was passed
*/
return ("");
}
/*
Although not part of your question, I have
included a short validation routine.
*/
function validate()
{
var x = document.forms["myForm"];
var submitOK = true;
var messageText =
"What a suprise! Please correct the error in your ways." +
" Please remove the asterisk ( * ) in the field.";
if (x.seminar.value.indexOf("*") >= 0)
{
alert(messageText);
submitOK = false;
}
return submitOK;
}
</script>
</head>
<body>
<p>Retrieve data passed as search value.</p>
<form name="myForm"
action="http://www.natAValidWebAddress.com"
method="POST"
onsubmit="return validate();">
<SCRIPT type="text/javascript">
var input = getUrlValue("Seminartitel");
/*
document.write will paste data into the document
as the document is loaded.
*/
document.write(
"<input type=\"text\" size=\"40\" name=\"seminar\"" +
"value=\"" + input + "\">");
</script>
<p><input type="submit"></p>
</form>
</body>
</html>
This line will show you the generated html plus everything else:
javascript
:'<html><head><title>SourceFileListing<\/title><\/head><body><c
ode><ol><li>'+(document.documentElement||document. body).innerHTML.replace
(/&/g,"&").replace(/</g,"<").replace(/%20%20/g," %20").replac
e(/\r\n/g,"<li>").replace(/\n/g,"<li>").replace(/\r/g,"<li>")+'<\/ol><\/c
ode><\/body><\/html>';
It wrapped! In IE, you can change innerHTML to outerHTML.
Robert