...

View Full Version : Passing variables between forms using URL GET and POST



just he
09-03-2010, 03:15 PM
Hi,

There are different ways by which values of variables can be passed between forms. One of the ways is to use the setTimeout to pass the values or data. Here the biggest advantage is we can pass data to a different site even running automatically.

I would need from someone a bit of help to pass the variable links from form1 to variable strLink in form2 using SetTimeout.

We have the following schema:

An options select menu where value of the option, sent with a submitted form, is specified with the value attribute. In the absence of a VALUE attribute, the value is the content of the option element.



<html>
<head>
</head>
<body>
<form name="form1" method="get" >
<select name="links">
<OPTION VALUE="http://www.as.com/">El Mundo
<OPTION VALUE="http://www.atb.com.bo/">El Pais
<OPTION VALUE="http://www.cadenadial.com/">Bizgrok
<OPTION VALUE="http://www.cadenaser.com/">Eclab
<OPTION VALUE="http://elsa.berkeley.edu/">Elsa
<OPTION VALUE="http://www.caracol.com.co/">Factfinder
<OPTION VALUE="http://fairmodel.econ.yale.edu/">Fairmodel
<OPTION VALUE="http://www.cincodias.com/">Village
<OPTION VALUE="http://www.continental.com.ar/">Levine
<OPTION VALUE="http://www.literature.org/">Literature.org
<OPTION VALUE="http://www.literatura.org/Gusman/frasquito.html">Frasquito
<OPTION VALUE="http://www.literatura.org/Gusman/villa1.html">Villa
<OPTION VALUE="http://www.literatura.org/Gusman/lgcrific.html">Mapa
<OPTION VALUE="http://www.literatura.org/Gusman/lgcrific.html">Mapa
</select>
</form>


Timing events. We are executing some code after a specified time-interval.




<script>
setTimeout('document.form1.links.value = document.form2.strLink.value',2000);
</script>


You can see in the below case the values can be posted to another form.




<form name=form2 method=post action="convertx.asp">
<input type="text" name="strLink">
<input type="submit" name="btnSubmit" value="Show">
</form>

By post method of form submission we can automatically send more number or length of data using SetTimeout.


<script type="text/javascript" language="JavaScript">
btnsubmit = document.form2.submit();
setTimeout('btnsubmit',2000);
</script>



</body>
</html>


Any help will be much appreciated!

Just he!

http://up7.vox.com/6a00cd9722b0bf4cd500d41430c0d23c7f-50si

Philip M
09-03-2010, 03:50 PM
The best way to pass data from one page to another is by using a cookie. setTimeout() does not come into it.

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

just he
09-03-2010, 04:01 PM
I want fill out the variable strlink in form2 (same page) automatically by settimeout. In order by settimeout I want send the value of the strlink to convertx.asp

The 2 steps are not possible using settimeout or just the last? Sorry by my ignorance, but how I create a cookie. In javacript?

Just he!

Philip M
09-03-2010, 04:12 PM
Passing data from one page to another using (Javascript) cookies has been covered in this forum a zillion times.

Old Pedant
09-03-2010, 07:19 PM
He doesn't want to pass by cookies. He wants to send *POST* data in his <form> to a subsequent ASP page:


<form name=form2 method=post action="convertx.asp">

But I can't see, at all, what his problem is. That should be easy.

I'm not sure, but I *THINK* his problem is just this code:


<script type="text/javascript" language="JavaScript">
btnsubmit = document.form2.submit();
setTimeout('btnsubmit',2000);
</script>

That clearly WILL NOT WORK. It invokes the submit() immediately, instead of waiting 2 seconds.

He should probably just do:


<script type="text/javascript" language="JavaScript">
setTimeout("document.form2.submit()",2000);
</script>

just he
09-03-2010, 09:42 PM
Dear Old Pedant,

You are right.

I believe I was not too clear with my explanation.

In the document body I put 2 forms. First form (form1) dealing with an OPTIONS MENU. The other form (form2) constains a request form posted to CONVERTX.HTM. What I want? I want auto pick up each link from OPTIONS MENU and automatically fill out the INPUT named "strLink" in form2. My goal: open in convertx.asp several source codes of web pages automatically. No typing!

Any help will be much appreciated!

Just he!


http://www.dhytex.com/viber/images/aplaceforsurfers.jpg

Old Pedant
09-03-2010, 09:55 PM
??? First you say

a request form posted to CONVERTX.HTM.
But you can *NOT* sent POST data to an HTML page. You can only send GET data to HTML pages.

But *THEN* you say

My goal: open in convertx.asp several source codes of web pages automatically.

Okay, you *can* send POST data to an ASP page.

But I don't pretend to understand how *ONE* ASP page is suppose to open "several source codes".

just he
09-03-2010, 10:09 PM
Well,

Not! In my first post I put

<
form name=form2 method=post action="convertx.asp">

All data must be synchronized!

I will send one source code only to convertx.asp at once. By now I would like to know how to post a request form automatically. I have tested several alternatives (with form2), but none works!


<form name="form2" method="post" action="convertx.asp">
<input type="text" name="strLink">
<script type="text/javascript" language="JavaScript">
setTimeout("document.form2.btnSubmit()",5000);
</script>
</form>




<form name="form2" method="post" action="convertx.asp">
<input type="text" name="strLink">
<input type="submit" name="btnSubmit" value="Show">
</form>
<script type="text/javascript" language="JavaScript">
setTimeout("document.form2.btnSubmit()",5000);
</script>



<form name="form2" method="post" action="convertx.asp">
<input type="text" name="strLink">
<input type="submit" name="btnSubmit" value="Show">
<script type="text/javascript" language="JavaScript">
setTimeout("document.form2.btnSubmit()",5000);
</script>
</form>



<form name="form2" method="post" action="convertx.asp">
<input type="text" name="strLink">
<input type="submit" name="btnSubmit" value="Show">
<script type="text/javascript" language="JavaScript">
setTimeout("document.form2.submit()",5000);
</script>
</form>


Just he!

http://www.dhytex.com/viber/images/aplaceforsurfers.jpg

Old Pedant
09-03-2010, 10:21 PM
The LAST one you show there *SHOULD* work.



<form name="form2" method="post" action="convertx.asp">
<input type="text" name="strLink">
<input type="submit" name="btnSubmit" value="Show">
<script type="text/javascript" language="JavaScript">
setTimeout("document.form2.submit()",5000);
</script>
</form>

What happens when you try it???

just he
09-04-2010, 12:20 AM
Well, taking in mind the form2 it works if I fill out the input text. In other way, not.

Now I will do a question regarding this script. If I have an options menu:


<form name="form1" method="get" >
<select name="links">
<OPTION VALUE="http://www.as.com/">El Mundo
<OPTION VALUE="http://www.continental.com.ar/">Levine
<OPTION VALUE="http://www.literatura.org/Gusman/villa1.html">Villa
<OPTION VALUE="http://www.literatura.org/Gusman/lgcrific.html">Mapa
<OPTION VALUE="http://www.literatura.org/Gusman/lgcrific.html">Mapa
</select>

+

Other form to fill out:


<form name="form2" method="post" action="convertx.asp">
<input type="text" name="strLink" value=function()>
<input type="submit" name="btnSubmit" value="Show">
<script type="text/javascript" language="JavaScript">
setTimeout("document.form2.submit()",2000);
</script>
</form>

How I do to auto input the input text (form2) with a function that call each option menu automatically?

How I do a function like this:


for i = 1 to end of file
do
document.form1.links.options[i].selected)
document.form2.strLink = "http://www.weather.com
enddo
endfor

Just he

http://www.dhytex.com/viber/images/aplaceforsurfers.jpg

Old Pedant
09-04-2010, 12:51 AM
Tell you what, FIRST show me what is in your "convertx.asp" page code.

So we can see if it even makes sense to approach it in this way.

just he
09-04-2010, 01:24 AM
In the convertx.asp there is a function to strip out the html tags using regular expressions (ASP Classic)inside a textarea. So, I can see the plain source code.No iframes are used!


Just he!

http://www.dhytex.com/viber/images/aplaceforsurfers.jpg



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum