Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

posting parameters to another page without having to press a button

Status
Not open for further replies.

cyprus106

Programmer
Apr 30, 2001
654
I have to post several parameters to a newly opened page. Unfortunately, to do that I have to have users click a button inside of a form to send all of the parameters. Is there any way to send them automatically or simulate a button clivk or something?? thanks!

Cyprus
 
The values can be stored in the query string portion of the URL for the page, as in:
Code:
[URL unfurl="true"]http://www.mydomain.com/mypagename.htm?value1=7&value2=Bob[/URL]
No form submission required.
 
what about hidden values? they've absolutely got to be hidden, unfortunately.

Cyprus
 
Good call! never crossed my mind...

Cyprus
 
If you are currently using a form, you could call a JavaScript form.submit() function to auto post the form. No user needed.

DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
thats what i was looking for! I just call that line that you fed, I'm assuming...

Cyprus
 
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
function submitMe(){
document.forms[0].submit();
}
</SCRIPT>

Just call the function when you want it to go.

DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
I know this is horrible, but please bear with me: JS just isn't my strong suit... How do I call the function from the form? Every time I try to it just comes otu as text on the html and whenever i ptu it inside of the <>s it just sits there...

Cyprus
 
OK, You'd put DeZiner's script between your <head></head> tags.

Then, JavaScript being an event-driven language, depending on when you want the form to be submitted, you would call the function on some event that occurs on your page.

For example if you wanted the form to submit when the user leaves the page you would code it into the <body> tag's onUnload event:
Code:
<body onUnload=&quot;submitMe()&quot;>

Or if you wanted it submitted as soon as a particular field is updated you would code it into that field's onChange event:
Code:
<input type=&quot;text&quot; id=&quot;postcode&quot; onChange=&quot;submitMe()&quot;>

If you look <-- That way, you'll see a link to DevGuru in the Partners box. They have a good reference for Javascript that covers all of the events that can occur on various elements in a page.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top