passing params to html-form

  • Thread starter Holger Butschek
  • Start date
H

Holger Butschek

Hi folks,

first of all, I'm absolutly new to javascript. I have designed a html-form
and am trying to path parameters with the suffix of i.e.
?Seminartitel=hallowelt in the url.

In the head of the called page I put the following script (I found it some
where, many thanks to him):

<script language="JavaScript">

function GetUrlValue(Entry)
{
urlText=location.search;
fc=urlText.slice(0,1);
if(fc=="?")
{
l=urlText.length;
urlText=urlText.slice(1,l);
ArgSet=urlText.split("&");
for(i=0;i<ArgSet.length;i++)
{
as=ArgSet.split("=");
if(as[0]==Entry)
{
return (as[1]);
}
}
return ("");
}
}
</script>

Now, I would like to preset the field Seminar of the form with the value
Seminartitel.

<input type="text" size="40" name="Seminar" value=" ... xxxxxxxx ......">

Many thanks,
Holger Butschek
 
T

Thomas 'PointedEars' Lahn

Robert said:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

The system identifier (the URL of the DTD) is missing in this declaration.
It should be

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
[...]
<SCRIPT type="text/javascript">
/*

Most folks lower case the first word in the name of
functions and variables.
True.

Using an upper case letter
in the first word is reserved for functions which
initialize class members:
var myCar = new Car("VW");

That is a *constructor*. Using the "new" keyword when calling it, returns
a reference to an object, not to a "class member". There are no classes
in ECMAScript < 4, JavaScript < 2 and JScript < 6, those are languages
implementing only prototype-based inheritance.
Anyway, be consistant.
ACK

<form name="myForm"

A "name" attribute is not required here ...
action="http://www.natAValidWebAddress.com"
method="POST"
onsubmit="return validate();">

.... if you pass a reference to the calling object:

function validate(x)
{
// This is no longer required then:
 // var x = document.forms["myForm"];
...
}
....
onsubmit="return validate(this);">
[...]
document.write(
"<input type=\"text\" size=\"40\" name=\"seminar\"" +
"value=\"" + input + "\">");

Early JavaScript versions, and ECMAScript implementations allow for using
both the " and the ' character to be used as string literal delimiter. To
make use of that makes especially DHTML easier to read and to maintain.
More, some HTML attributes have default values and thus can be omitted:

document.write(' said:
[...]
<p><input type="submit"></p>

This is not a paragraph, use the "div" element instead of the "p" element.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top