Click to See Complete Forum and Search --> : submitting a variable to script using javascript


poab
04-04-2003, 06:33 AM
Hi,

I want to submit a variable to a script (asp). I'm assuming the best way of doing this is with javascript...

I have an html form. It has a submit button. When it's pressed the page is reloaded and asp checks what was pressed, changing the page as necessary. (the asp uses Request.Form();)

I want to do exactly the same thing but with a link rather than with a form.

Any body know how?

cheers

pyro
04-04-2003, 07:40 AM
I don't know any ASP (I use PHP), so I can't give you direct help, but I can point you in the right direction. ;)

What you will want to do is use a query string in your link, such as http://www.yourdomain.com/somepage.asp?yourvariable=somevariable. You can then use some ASP on the somepage.asp page to strip the query string and get the values.

poab
04-04-2003, 07:46 AM
Hi,

thanks for the reply. Sadly it won't work as I don't want to refer to individual pages, I want the location bar to read:

http://www.myDomain.com/myPage/

instead of

http://www.myDomain.com/myPage/pageOne.asp

Should have mentioned that shouldn't I?

How about just submitting a form with javascript. Is that possible? As in I call a function from a link which submits a form for me.

cheers.

khalidali63
04-04-2003, 07:50 AM
yes, you can submit the form using a function,from a link this is how you will do it.

<a href="javascript:submitFormFunction()">Submit Form</a>

in JS the function

function submitFormFunction(){
document.formName.submit();
}

Cheers

Khalid

poab
04-04-2003, 07:58 AM
Thanks, I'll give that a try:)

cheers.