PDA

View Full Version : Javascript question - maybe...


kcates
03-30-06, 06:56 AM
I'm not a javascript programmer, so let's see if I can explain what I'm trying to do...

I have a miva script that will send a canned email message, but it needs to know which message to send, identified by a number.

There is a web page where the user will enter the email address and some other information, and that contains a form that will pass the data to the miva script. Let's call this the data entry page.

The user gets to the data entry page by clicking on a link that might look like this - "www.whatever.com/whatever.html?arg=1", so the link will identify the message that will ultimately be sent by the script.

I assume that when the data entry page is loaded by the browser, I can use javascript to access the argument (not sure exactly how)?

But I then need to get that argument value into one of the form variables.

Is this do-able, or am I totally confused...?

Thanks!
Ken

Vic - WolfPaw Computers
03-30-06, 07:58 AM
The easiest way to accomplish this would be to set the arg= in a hidden field.

<input type=hidden id=argument name=arg value=1>

Now you can use a javascript getElementbyID.arg.value to extract the value into a javascript var.

var myVar=document.getElementById("argument");

kcates
03-30-06, 08:10 AM
If I understand your answer correctly, I want the data entry page to be general purpose, with the link that the person uses to be the thing that determines the arg value. Hence the usage of ?arg=1 in the link.

Then pass the argument from the URL, through to a form variable on the data entry page, and finally via the form to the miva script.

I could use a totally different data entry page where the message ID is defined by a hidden variable, but I wanted to make it general purpose...

Vic - WolfPaw Computers
03-30-06, 08:27 AM
Yes, since you would be using form based input to collect the data - use the input tag to assign an ID and you can still poll the variable from the form field.