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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to insert javascript variable into form redirect

    Hi, I am a new guy here but wondering if anyone can help. I need to redirect users to a page based on the valua of a variable. ie if the variable is "widgit.com/moreinfo1.htm" then they get rediected there. The variable changes based on several onclicks on the page. The variable is not the problem. I am just not sure how to insert it into the form code.

    Here is my rather feeble attempt so far...

    In the header..

    Code:
    <SCRIPT LANGUAGE="JavaScript">
    var goforward = 'http://widgit.com/info1.htm';
    </SCRIPT>
    In the body...


    Code:
    <TD><form name="calc2" method="POST" action="http://fp1.formmail.com/cgi-bin/fm192">
    <input type="hidden" name="_pid" value="51921">
     <input type="hidden" name="_fid" value="AIE25230">
     <input type="hidden" name="recipient" value="1">
    <input type="hidden" name="Title">
    <input type="hidden" name="redirect" value=goforward>
    I also tried putting speech marks etc around the goforward eg value='goforward' or value="goforward".

    Anyone help? Thanks, James

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Once the variable has been assigned you would need to go something like

    document.calc2.redirect.value=goforward
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #3
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK tried that. But still seems to be a bug. Now I have in the head...

    Code:
    <SCRIPT LANGUAGE="JavaScript">
    var goforward = 'http://widgit.com/info1.htm';
    </SCRIPT>
    In the body I have an onclick which reads...

    Code:
    <TD vAlign=top width=45><div class="pic"><A href="#topanchor"
    onclick="
    goforward = 'http://www.widgit.com/index4.htm'; 
    document.calc2.redirect.value=goforward;">
    <IMG name=imagew15 src="http://widgits.co.uk/widgit.jpg" Title="widgit" border=0></A></div></TD>
    Lower down the form reads...

    Code:
    <TD><form name="calc2" method="POST" action="http://fp1.fwidgit.com/cgi-bin/fm192">
    <input type="hidden" name="_pid" value="4354">
     <input type="hidden" name="_fid" value="AIE25440">
     <input type="hidden" name="recipient" value="1">
    <input type="hidden" name="Title">
    <input type="hidden" name="Redirect" value=goforward>
    <input class=text3 type="text" name="email" size="45">
    <input type="submit" value="Submit Order">
    </TD>
    </TR>
    </form>
    After the click I am hoping that it redirects to http://www.widgit.com/index4.htm. At the moment i just receive a form with the text "Redirect: http://www.widgit.com/index4.htm. There is no actual redirection.

    Thanks


  •  

    Posting Permissions

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