473,771 Members | 2,357 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

passing params to html-form

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=h allowelt 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="JavaS cript">

function GetUrlValue(Ent ry)
{
urlText=locatio n.search;
fc=urlText.slic e(0,1);
if(fc=="?")
{
l=urlText.lengt h;
urlText=urlText .slice(1,l);
ArgSet=urlText. split("&");
for(i=0;i<ArgSe t.length;i++)
{
as=ArgSet[i].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

--
Erstellt mit M2, Operas revolutionärem E-Mail-Modul:
http://www.opera.com/m2/
Jul 23 '05 #1
2 2026
In article <op************ **@news.butsche k.com>,
Holger Butschek <ho****@butsche k.com> wrote:
I have designed a html-form
and am trying to path parameters with the suffix of i.e.
?Seminartitel=h allowelt 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=p ass

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(ent ry)
{
/* Without the var, you are declaring this
variable a global variable. */
var urlText=locatio n.search;
var fc=urlText.slic e(0,1);
if (fc=="?")
{
var l=urlText.lengt h;
urlText=urlText .slice(1,l);
var argSet=urlText. split("&");
for (var i=0;i<argSet.le ngth;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.valu e.indexOf("*") >= 0)
{
alert(messageTe xt);
submitOK = false;
}

return submitOK;

}
</script>
</head>
<body>
<p>Retrieve data passed as search value.</p>
<form name="myForm"
action="http://www.natAValidWe bAddress.com"
method="POST"
onsubmit="retur n validate();">

<SCRIPT type="text/javascript">
var input = getUrlValue("Se minartitel");
/*
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:'<ht ml><head><title >SourceFileList ing<\/title><\/head><body><c
ode><ol><li>'+( document.docume ntElement||docu ment.body).inne rHTML.replace
(/&/g,"&amp;").repl ace(/</g,"&lt;").repla ce(/%20%20/g,"&nbsp;%20"). replac
e(/\r\n/g,"<li>").repla ce(/\n/g,"<li>").repla ce(/\r/g,"<li>")+'<\/ol><\/c
ode><\/body><\/html>';

It wrapped! In IE, you can change innerHTML to outerHTML.

Robert
Jul 23 '05 #2
Robert wrote:
<!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.natAValidWe bAddress.com"
method="POST"
onsubmit="retur n validate();">
.... if you pass a reference to the calling object:

function validate(x)
{
// This is no longer required then:
*// var*x*=*documen t.forms["myForm"];
...
}
....
onsubmit="retur n 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( '<input name="seminar" value="' + input + '" size="40">');
[...]
<p><input type="submit"></p>


This is not a paragraph, use the "div" element instead of the "p" element.
PointedEars
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1922
by: Tole | last post by:
hi all, i have some doubts in passing variables by references in php. i usually use class blah { function Params( &$params) { $this->params =& $params; } }
10
125462
by: Resant | last post by:
I have a query : Exec 'Select * From Receiving Where Code In (' + @pCode + ')' @pCode will contain more than one string parameter, eg : A1, A2, A3 How can i write that parameters, I try use : set @pCode='A1','A2','A3' but get an error : Incorrect syntax near ','
0
1408
by: Mihaly | last post by:
Hello, i'm using a VC++ com+ object, it's reference in vs .net, this com object have a function that have to params, the interop com object recive Object Params and the original com object say that this params are variants. I'm traying to pass "object" variables to the params but the com object return an error or a null object, the piece of code that i'm using is: using AgenObj;
2
15128
by: Tobias Olbort | last post by:
Hello, i've a outer function, which takes a params-array as a parameter. I want to pass this array to inner function with a params-array (e. g. string.format). When i've passed an integer to the outer function, the string.format sets the string-value "System.Object" at the position of {0}. How can i get it work, so that all my values, passed to the outer
1
1279
by: craigkenisston | last post by:
Hi, I'm trying to create a generic function to call stored procedures in a SQL Server database. I'm passing the params, values and the direction of the params in arrays. The function is working, and I get the output parameters values back in my the array I sent, however, I'd like to have the values in my original variables, please see below :
1
3141
by: Darsin | last post by:
Hi all, I am a new programmer to C# and i am having a following problem. I want to make a single method which takes a variable length array and display it contents. i have defined the method as: public void DisplayVals(params object objArray) { foreach (object o in objArray) Console.WriteLine(o.ToString()); }
1
2525
by: raf_z | last post by:
Hi, I'm running a website with Asp.NET, and on one of the pages i have a crystal report with 3 user-populated parameters. However, not all params might be selected. Example: Parameters: 1. EmployeeID 2. First Name 3. Last Name
12
6905
by: Dennis D. | last post by:
Hello: I want a function to return three variables to the calling procedure: Private Function CalcTimes(ByVal iAddDays as Integer, ByVal iAddHours as Integer, ByVal iAddMins as Integer) As Array Variable values are calculated in the function. Calling procedure receives the values preferably into variables of the same
2
2979
by: Sike | last post by:
Hi everyone, I've been browsing this and a few other related newsgroups trying to get my head around this problem, and so far all the trails seem to go cold, without an acceptable solution being reached. I'm posting here because there seems to be a few MVP's knocking around, and if they dont know, then it's a safe bet nobody does. I'm beginning to think that what I want to do is simply not possible - but i'll put it out there once...
3
2293
by: q-rious | last post by:
Hello All, 1. I would like to pass some variables (x and y below) from Javascript to PHP, process them in PHP, and return some other variables (a abd b) back to Javascript. --(x,y)-- --(a,b)-- 2. The variables x and y are not known to HTML directly, so I can not pass them to PHP as:
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10102
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.