37 users online (0 members and 37 guests)  


  Results 1 to 3 of 3

Related

  1. Passing Javascript variables to a form    Forum: Javascript Forum
    Replies: 0
  2. Passing PHP variable to Javascript    Forum: PHP Forum
    Replies: 5
  3. convert a perl variable to javascript variable    Forum: Javascript Forum
    Replies: 0
  4. Help!! - passing variable    Forum: Website Scripts Forum
    Replies: 0
  5. Replies: 5
  1. #1
    tjanson's Avatar
    New User

    Status
    Offline
    Join Date
    Jul 2004
    Posts
    14

    Passing a Javascript Variable Value through a form

    Hi-

    I could use your insight here. I've generated an order number based on getDate which displays for the user when they open the page. What I'd like to do is pass that value through the form in a hidden field. I think my approach is right, but maybe not. I'm terrible with javascript syntax.
    Code:
    <SCRIPT LANGUAGE="JAVASCRIPT">
    <!--
    var d = new Date();
    var curr_date = d.getTime();
    //-->
    </SCRIPT>
     
    <table width="592" cellpadding="6" cellspacing="1" id="table">
                         <tr>
                         <form action="/local-bin/FromProcessor" method="POST">
    <td width="161" valign="top">Request Tracking Number:</td>
    <td width="402" valign="top"><input type="hidden" name="Request Tracking Number" value="document.write(curr_date);">
    <script language="javascript">
                                 document.write(curr_date);
                                </script> </td>
    </tr></table></form>
                     </body>
                     </html>
    Obviously this:

    value="document.write(curr_date);">

    is not working. Help?! Thanks in advance.
    Last edited by HTML; 10-11-2007 at 01:09 PM.

  2. #2
    hermoine's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Mar 2007
    Posts
    32

    Thumbs up Re: Passing a Javascript Variable Value through a form

    Instead of this you give it as below
    javascript:
    Code:
    <SCRIPT LANGUAGE="JAVASCRIPT">
    var d = new Date();
    var curr_date = d.getTime();
    document.getElementById('Request Tracking Number').value=curr_date;
    </SCRIPT>
    and in the html just change the following line...
    Code:
    <input type="hidden" name="Request Tracking Number" id="Request Tracking Number" value="">

  3. #3
    Wilmor's Avatar
    New User

    Status
    Offline
    Join Date
    Jan 2008
    Posts
    1

    Re: Passing a Javascript Variable Value through a form

    Hello, I'm having the almost the same issue. I want to pass the document.write (value) to my Form value. here is my code:

    <script type="text/javascript" src="ordersys/source/pricelist.js"></script>

    <script type="text/javascript">

    document.write (lg_conch_pendant_h);

    </script>


    <form name=order action="ordersys/gettaxes.html" onSubmit="AddToCart(this);" style="text-align: center">
    <input type=hidden name="ID_NUM" value="00001">
    <input type=hidden name="NAME" value="Past, present, and the future wedding bands">
    <input type=hidden name="PRICE" id="lg_conch_pendant_h" value="">


    PRICE is where i want to pass the script value to.

    any genius out there I'm cleaning the lamp for you.
    thanks.



Tags for this Thread