Issue with setting hidden value from url

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JCCDevel

    Issue with setting hidden value from url

    Hi All,

    I'm not too proficient in Javascript but am trying to help a friend
    out. Bascially, the page we are having trouble with is loaded with a
    numerical value in the url string. Example:



    I then parse the string to get the total. I then want to assign the
    value to a hidden form value
    (document.form1 .FeeCalcTotalDe cimal.value) The hidden value is to be
    used to post to a bank's website.

    I'm sure this is just a syntax issue, but I'm stumped. Keep getting
    "document.form1 .FeeCalcTotalDe cimal.value is null or not an object."

    <CODE>

    <script language="JavaS cript">

    function parseGetVars() {
    var getVars = new Array();
    var qString = unescape(top.lo cation.search.s ubstring(1));
    var pairs = qString.split(/\&/);
    for (var i in pairs) {
    var nameVal = pairs[i].split(/\=/);
    getVars[nameVal[0]] = nameVal[1];
    }
    return getVars;
    }
    </script>

    <script>
    var g = parseGetVars();
    for (var i in g)
    document.writel n('Your total fee is $' +g[i]+'<br>');
    document.form1. FeeCalcTotalDec imal.value = '+g[i]+' ; THIS ISN'T
    WORKING!!


    </script>
    <br />
    </font</div>
    <table width="715" height="52" border="0">
    <tr>
    <td align="center" width="374" height="48"<for m
    name="form1" method="post" action="https://secure.linkpt.n et/lpcentral/
    servlet/lppay">
    <input type="hidden" name="txntype" value="sale">
    <input type="hidden" name="storename " value="10011848 58">
    <INPUT type="hidden" name="chargetot al"
    value="FeeCalcT otalDecimal">
    <input type="hidden" name="suppressT itle" value="true">
    <input name="Submit" type="submit" id="Submit" value="Submit">
    </td>
    <td width="331">
    </div>
    </form></td>
    </tr>
    </table>

    </CODE>

    Thanks in advance for your help!

    JCC
  • Thomas 'PointedEars' Lahn

    #2
    Re: Issue with setting hidden value from url

    JCCDevel wrote:
    I'm not too proficient in Javascript but am trying to help a friend
    out.
    FOAF? Yeah, sure ;-)
    [...]
    I then parse the string to get the total. I then want to assign the
    value to a hidden form value
    (document.form1 .FeeCalcTotalDe cimal.value) The hidden value is to be
    used to post to a bank's website.
    >
    I'm sure this is just a syntax issue, but I'm stumped. Keep getting
    "document.form1 .FeeCalcTotalDe cimal.value is null or not an object."
    The script is located before the control in the markup; the control does
    not exist at that point. Besides, your markup is not Valid[1] and you are
    using proprietary syntax. Use instead, after the control was parsed:

    document.forms["form1"].elements["FeeCalcTotalDe cimal"].value

    [1] http://validator.w3.org/


    HTH

    PointedEars
    --
    realism: HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness: XHTML 1.1 as application/xhtml+xml
    -- Bjoern Hoehrmann

    Comment

    • Evertjan.

      #3
      Re: Issue with setting hidden value from url

      JCCDevel wrote on 17 apr 2008 in comp.lang.javas cript:
      document.form1. FeeCalcTotalDec imal.value = '+g[i]+' ; THIS ISN'T
      WORKING!!
      >
      reason1:

      The form form1 is not yet declared and so not yet part of the DOM.

      reason2:

      <INPUT type="hidden" name="chargetot al"
      value="FeeCalcT otalDecimal">

      Should be something like:

      <INPUT type="hidden" name="FeeCalcTo talDecimal"
      value="">


      =============== ==============

      Why use outmoded
      <script language="JavaS cript">
      and
      <script>
      where
      <script type='text/javascript'>
      is the standard?

      Why split the script in two?

      Change 1
      document.form1.
      to
      document.forms. form1.

      <table width="715" height="52" border="0">
      use css styles instead!

      In the end,
      better fill the hidden input with serverside code.
      ASP example:

      <INPUT type="hidden" name="FeeCalcTo talDecimal"
      value = '<% = serversideValue %>'>


      --
      Evertjan.
      The Netherlands.
      (Please change the x'es to dots in my emailaddress)

      Comment

      • JCCDevel

        #4
        Re: Issue with setting hidden value from url

        On Apr 17, 12:05 pm, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
        wrote:
        JCCDevel wrote:
        I'm not too proficient in Javascript but am trying to help a friend
        out.
        >
        FOAF?  Yeah, sure ;-)
        >
        [...]
        I then parse the string to get the total. I then want to assign the
        value to a hidden form value
        (document.form1 .FeeCalcTotalDe cimal.value) The hidden value is to be
        used to post to a bank's website.
        >
        I'm sure this is just a syntax issue, but I'm stumped.  Keep getting
        "document.form1 .FeeCalcTotalDe cimal.value is null or not an object."
        >
        The script is located before the control in the markup; the control does
        not exist at that point.  Besides, your markup is not Valid[1] and you are
        using proprietary syntax.  Use instead, after the control was parsed:
        >
          document.forms["form1"].elements["FeeCalcTotalDe cimal"].value
        >
        [1]http://validator.w3.or g/
        >
        HTH
        >
        PointedEars
        --
            realism:    HTML 4.01 Strict
            evangelism: XHTML 1.0 Strict
            madness:    XHTML 1.1 as application/xhtml+xml
                                                            -- Bjoern Hoehrmann
        Thank you both for your suggestions. I have asked my friend(and yes
        Thomas, it is for a friend - she is strictly a designer and hasn't had
        to do this type of thing before) to plug this into her page. I'm used
        to using server side code and her page is just stand-alone. I truly
        appreciate your help!

        Comment

        Working...