Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

JavaScript - Passing Value from TextField to another Page

Options
  • 23-06-2007 6:40pm
    #1
    Registered Users Posts: 527 ✭✭✭


    Hi all,

    I have a form on one page that calculates a total into a textfield.

    I want to set this value passed into the total(textfield) to a value on the new page's form called ppForm2.

    I have "Googled" :- passing value from one form to another +javascript
    and have followed loads of tutorials and examples to which I could get none to work.

    I think the problem might be something to do with the form that the textfield originates on is using <... action="formmail.asp">


    Anyway, here is the code from the original window:
    <form id="form1" name="form1" method="GET" action="formmail.asp">
    ...
    ...
    <input type="text" name="textfield2" onfocus="this.blur()" readonly="readonly" style="border:3"/>
    

    Now here's the code on the page I want the value to be passed..
    <SCRIPT LANGUAGE="JavaScript">
    var bdep = top.opener.document.getElementById("form1").textfield2.value;
    document.ppForm2.amount.value = bdep;
    alert(bdep);
    </SCRIPT>	
    ...
    ...
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="ppForm2" id="ppForm2">
    <input type="hidden" name="cmd" value="_xclick" />
              <input type="hidden" name="bn" value="webassist.dreamweaver.4_0_3" />
              ...
              <input type="hidden" name="currency_code" value="EUR" />
              <input type="hidden" name="undefined_quantity" value="0" />
              ...
              ...
              <input type="hidden" name="no_shipping" value="0" />
              <input type="hidden" name="no_note" value="0" />
              ...
              <input type="hidden" name="amount" value= "" />
              <input type="image" name="ppButton" id="ppButton" src="http://images.paypal.com/images/x-click-but6.gif" border="0" alt="Make payments with PayPal, it's fast, free, and secure!" style="display:visible" />
    
    

    I have tried many variations on var bdep = top.opener.document.getElementById("form1").textfield2.value; to which none have worked for me :(

    I hope someone can help with this one as I have spent ages trying to get this to work.


    Thanks in advance.

    Seán


Comments

  • Registered Users Posts: 872 ✭✭✭grahamor


    store the value in a cookie.

    type it into google and you can find out how to do it. Its simple to set and get the value from a cookie.

    Hope it helps


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    give the field an id as well as a name
    <input type="text" name="textfield2" id="textfield2"... />
    

    then use getElementById
    document.getElementById("textfield2").value
    

    in your case you might need to look into parsing the querystring as your form is set to get.


  • Closed Accounts Posts: 1,106 ✭✭✭MoominPapa


    Try this:

    First page:
    <form id="Form1" action="Page2.asp" method="GET">
    <input type="text" name="textField" style="border:3"/>
    <input type="submit" name="submit" value="submit" />
    </form>

    Second Page:
    <% String passedValue=request.getParameter("textField"); %>
    <form id="form1">
    <input type="text" name="textfield2" value=<%= passedValue %> />
    </form>

    Not sure if it'll work as I don't use asp


  • Registered Users Posts: 527 ✭✭✭Sean^DCT4


    @louie
    I tried that but it didn't work


    grahamor wrote:
    store the value in a cookie.

    type it into google and you can find out how to do it. Its simple to set and get the value from a cookie.

    Hope it helps

    Yes it did, works great now.



    Thanks for the help people.

    Seán


  • Registered Users Posts: 527 ✭✭✭Sean^DCT4


    .....


  • Advertisement
Advertisement