Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New Coder
    Join Date
    Sep 2010
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing variables between forms using URL GET and POST

    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!

    Last edited by just he; 09-03-2010 at 03:21 PM.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    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.

  • #3
    New Coder
    Join Date
    Sep 2010
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Passing data from one page to another using (Javascript) cookies has been covered in this forum a zillion times.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    He doesn't want to pass by cookies. He wants to send *POST* data in his <form> to a subsequent ASP page:
    Code:
    <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:
    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:
    Code:
    <script type="text/javascript" language="JavaScript">
    setTimeout("document.form2.submit()",2000);
    </script>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    New Coder
    Join Date
    Sep 2010
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!



  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    ??? 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".
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #8
    New Coder
    Join Date
    Sep 2010
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

    Last edited by just he; 09-03-2010 at 10:11 PM.

  • #9
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    The LAST one you show there *SHOULD* work.

    Code:
    <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???
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #10
    New Coder
    Join Date
    Sep 2010
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

    Last edited by just he; 09-04-2010 at 12:48 AM.

  • #11
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #12
    New Coder
    Join Date
    Sep 2010
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

    Last edited by just he; 09-04-2010 at 01:28 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •