Syntax Help....

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ross M. Greenberg

    Syntax Help....

    I'm going nuts!

    I need an HTML line of the form <input type="hidden" name ="shipping_1 "
    value="12.34">

    where "12.34" represents a variable.

    Between <script></script> tags what is the format and syntax to have good HTML
    emitted for inclusion in a .htm?

    Help!

    Ross

  • HikksNotAtHome

    #2
    Re: Syntax Help....

    In article <vhmbehiu65v786 @corp.supernews .com>, "Ross M. Greenberg"
    <greenber-at-catskill.net> writes:
    [color=blue]
    >I'm going nuts!
    >
    >I need an HTML line of the form <input type="hidden" name ="shipping_1 "
    >value="12.34 ">
    >
    >where "12.34" represents a variable.
    >
    >Between <script></script> tags what is the format and syntax to have good
    >HTML
    >emitted for inclusion in a .htm?
    >
    >Help![/color]

    Are you trying to dynamically set its value? Or, when the page is loaded,
    create the input?

    document.formNa me.shipping_1.v alue = 12.34;

    will set its value.
    --
    Randy
    All code posted is dependent upon the viewing browser
    supporting the methods called, and Javascript being enabled.

    Comment

    • Ross M. Greenberg

      #3
      Re: Syntax Help....

      I named the form "fred". This being used to pass info to Paypal.

      <form name="fred" method="post" target="paypal"
      action="https://www.paypal.com/cgi-bin/webscr">
      <input type="hidden" name="shipping_ 1" value="12.34">
      ....
      <input type="submit" value="Pay" name="submit" onclick=clickit ();>
      </form>
      <script>
      function clickit(){docum ent.fred.shippi ng_1.value="123 .45";}
      </script>


      This should, I think, submit shipping_1 as 123.45 to paypal, but is instead
      submitting the original value of 12.34.

      Help!

      Thanks!

      Ross

      "HikksNotAtHome " <hikksnotathome @aol.com> wrote in message
      news:2003072020 1731.21428.0000 1182@mb-m23.aol.com...[color=blue]
      > In article <vhmbehiu65v786 @corp.supernews .com>, "Ross M. Greenberg"
      > <greenber-at-catskill.net> writes:
      >[color=green]
      > >I'm going nuts!
      > >
      > >I need an HTML line of the form <input type="hidden" name ="shipping_1 "
      > >value="12.34 ">
      > >
      > >where "12.34" represents a variable.
      > >
      > >Between <script></script> tags what is the format and syntax to have good
      > >HTML
      > >emitted for inclusion in a .htm?
      > >
      > >Help![/color]
      >
      > Are you trying to dynamically set its value? Or, when the page is loaded,
      > create the input?
      >
      > document.formNa me.shipping_1.v alue = 12.34;
      >
      > will set its value.
      > --
      > Randy
      > All code posted is dependent upon the viewing browser
      > supporting the methods called, and Javascript being enabled.[/color]

      Comment

      • Urs Rothenhäusler

        #4
        Re: Syntax Help....

        Did you try it with another event-handler - onsubmit?

        And I think the js-function should be before the form.

        Urs



        Ross M. Greenberg wrote:[color=blue]
        > I named the form "fred". This being used to pass info to Paypal.
        >
        > <form name="fred" method="post" target="paypal"
        > action="https://www.paypal.com/cgi-bin/webscr">
        > <input type="hidden" name="shipping_ 1" value="12.34">
        > ...
        > <input type="submit" value="Pay" name="submit" onclick=clickit ();>
        > </form>
        > <script>
        > function clickit(){docum ent.fred.shippi ng_1.value="123 .45";}
        > </script>
        >
        >
        > This should, I think, submit shipping_1 as 123.45 to paypal, but is instead
        > submitting the original value of 12.34.
        >
        > Help!
        >
        > Thanks!
        >
        > Ross
        >
        > "HikksNotAtHome " <hikksnotathome @aol.com> wrote in message
        > news:2003072020 1731.21428.0000 1182@mb-m23.aol.com...
        >[color=green]
        >>In article <vhmbehiu65v786 @corp.supernews .com>, "Ross M. Greenberg"
        >><greenber-at-catskill.net> writes:
        >>
        >>[color=darkred]
        >>>I'm going nuts!
        >>>
        >>>I need an HTML line of the form <input type="hidden" name ="shipping_1 "
        >>>value="12.34 ">
        >>>
        >>>where "12.34" represents a variable.
        >>>
        >>>Between <script></script> tags what is the format and syntax to have good
        >>>HTML
        >>>emitted for inclusion in a .htm?
        >>>
        >>>Help![/color]
        >>
        >>Are you trying to dynamically set its value? Or, when the page is loaded,
        >>create the input?
        >>
        >>document.form Name.shipping_1 .value = 12.34;
        >>
        >>will set its value.
        >>--
        >>Randy
        >>All code posted is dependent upon the viewing browser
        >>supporting the methods called, and Javascript being enabled.[/color]
        >
        >[/color]

        Comment

        • Ross M. Greenberg

          #5
          Re: Syntax Help....


          "Urs Rothenhäusler" <urs.rothenhaeu sler@epost.de> wrote in message
          news:3F1BEA11.9 010807@epost.de ...[color=blue]
          > Did you try it with another event-handler - onsubmit?[/color]

          Just did. No diff. Sigh.
          [color=blue]
          >
          > And I think the js-function should be before the form.[/color]

          Still no diff. Argh!


          Comment

          • Philip Ronan

            #6
            Re: Syntax Help....

            On 03.7.21 1:56 PM, Ross M. Greenberg wrote:
            [color=blue]
            > <input type="submit" value="Pay" name="submit" onclick=clickit ();>[/color]

            This probably won't do anything unless you put quotation marks around
            "clickit(); "

            But why not do it properly and put this in an onsubmit handler inside the
            FORM tag? After all, most browsers will submit the form if the user presses
            the enter key inside one of the form fields, so the submit button won't
            necessarily be pressed at all.

            Phil

            --
            Philip Ronan
            phil.ronanzzz@v irgin.net
            (Please remove the "z"s if replying by email)


            Comment

            • kaeli

              #7
              Re: Syntax Help....

              In article <vhnoodbsr0dv1a @corp.supernews .com>, "Ross M. Greenberg"
              <greenber-at-catskill.net> enlightened us with...[color=blue]
              > I named the form "fred". This being used to pass info to Paypal.
              >
              > <form name="fred" method="post" target="paypal"
              > action="https://www.paypal.com/cgi-bin/webscr">
              > <input type="hidden" name="shipping_ 1" value="12.34">
              > ...
              > <input type="submit" value="Pay" name="submit" onclick=clickit ();>
              > </form>
              > <script>
              > function clickit(){docum ent.fred.shippi ng_1.value="123 .45";}
              > </script>
              >
              >
              > This should, I think, submit shipping_1 as 123.45 to paypal, but is instead
              > submitting the original value of 12.34.
              >
              > Help!
              >[/color]

              <script>
              function clickit(frm)
              {
              frm.shipping_1. value="123.45";
              return true;
              }
              </script>

              <form name="fred" method="post" target="paypal"
              action="https://www.paypal.com/cgi-bin/webscr" onSubmit="click it(this)">
              <input type="hidden" name="shipping_ 1" value="12.34">
              ....
              <input type="submit" value="Pay" name="submit">
              </form>

              -------------------------------------------------
              ~kaeli~
              Black holes were created when God divided by 0.
              Not one shred of evidence supports the notion
              that life is serious.


              -------------------------------------------------

              Comment

              • Ross M. Greenberg

                #8
                Re: Syntax Help....


                "kaeli" <infinite.possi bilities@NOSPAM att.net> wrote in message >function
                clickit(frm)[color=blue]
                > {
                > frm.shipping_1. value="123.45";
                > return true;
                > }[/color]

                Exactly what I did. "12.34" is still showing up.


                Ross

                Comment

                • kaeli

                  #9
                  Re: Syntax Help....

                  In article <vhocallep2l4bf @corp.supernews .com>, "Ross M. Greenberg"
                  <greenber-at-catskill.net> enlightened us with...[color=blue]
                  >
                  >
                  > Exactly what I did. "12.34" is still showing up.
                  >
                  >[/color]

                  Not for me it didn't.
                  Are you sure you changed ALL the stuff I changed?

                  <html>
                  <head>
                  <title> New Document </title>
                  </head>

                  <body>
                  <script>
                  function clickit(frm)
                  {
                  frm.shipping_1. value="123.45";
                  return true;
                  }
                  </script>

                  <form name="fred" method="get" onSubmit="click it(this)">
                  <input type="hidden" name="shipping_ 1" value="12.34">
                  <input type="submit" value="Pay" name="submit">
                  </form>

                  </body>
                  </html>

                  --
                  -------------------------------------------------
                  ~kaeli~
                  Black holes were created when God divided by 0.
                  Not one shred of evidence supports the notion
                  that life is serious.


                  -------------------------------------------------

                  Comment

                  • Ross M. Greenberg

                    #10
                    Re: Syntax Help....


                    "Zac Hester" <news@planetzac .net> wrote in message
                    news:3f1c4681$1 @news.enetis.ne t...[color=blue]
                    >
                    > If this page is hosted somewhere, give us a URL and we can see what our
                    > browser turns up.
                    >[/color]

                    Sorry for the delay. Upstate NY, where I live, got hit with this mongo storm,
                    and I've been without powers for close to two days. Ug.

                    Try http://www.jewishtreasures.com/613.htm, scroll to the bottom, order 613,
                    then pick the radio button for International Shipping, then hit the "Checkout"
                    button.

                    This brings you to page in question. On this page I do an <input
                    type="hidden" name="shipping_ 1" value="1.00">
                    then when you hit Pay-by-Paypal I do a document.fred.s hipping_1.value ="12.30";
                    on submit, but only the 1.00 shows up in Paypal.....

                    Argh!

                    Help......

                    Ross


                    Comment

                    • Zac Hester

                      #11
                      Re: Syntax Help....

                      "Ross M. Greenberg" <greenber-at-catskill.net> wrote in message
                      news:vhu2hllmhh ujdd@corp.super news.com...[color=blue]
                      >
                      > "Zac Hester" <news@planetzac .net> wrote in message
                      > news:3f1c4681$1 @news.enetis.ne t...[color=green]
                      > >
                      > > If this page is hosted somewhere, give us a URL and we can see what our
                      > > browser turns up.
                      > >[/color]
                      >
                      > Sorry for the delay. Upstate NY, where I live, got hit with this mongo[/color]
                      storm,[color=blue]
                      > and I've been without powers for close to two days. Ug.
                      >
                      > Try http://www.jewishtreasures.com/613.htm, scroll to the bottom, order[/color]
                      613,[color=blue]
                      > then pick the radio button for International Shipping, then hit the[/color]
                      "Checkout"[color=blue]
                      > button.
                      >
                      > This brings you to page in question. On this page I do an <input
                      > type="hidden" name="shipping_ 1" value="1.00">
                      > then when you hit Pay-by-Paypal I do a[/color]
                      document.fred.s hipping_1.value ="12.30";[color=blue]
                      > on submit, but only the 1.00 shows up in Paypal.....
                      >[/color]

                      A couple things that might help:

                      1. Never put anything outside of the document. The code you are using to
                      update this value is after the closing "html" tag. While this should work
                      for most cases, it's not supposed to according to the basic document type.
                      All tree structures have to have a root node. In the case of an HTML
                      document's tree, the root node is the <html></html> element. Nothing can
                      exist outside of the root. The fact that IE lets us get away with it
                      doesn't make it right. This could affect the reassignment of this form
                      value since the "document.f red" object may be out of scope at this point.
                      Just a theory.

                      2. Try one of the many other ways to reference your form and see if that
                      helps. Try document.forms[document.forms. length-1], document.forms['fred'],
                      etc. You're doing it right, so I don't have an explanation why this would
                      work. I've also used a more robust way to retrieve the reference of a form,
                      by passing the form from within a form element. Make your clickit()
                      function like this:

                      <script type="text/javascript">
                      function clickit(formref ) {
                      formref.shippin g_1.value = "12.34";
                      }
                      </script>

                      Then,

                      <form ...>
                      ....
                      <input onclick="clicki t(this);" />
                      ....
                      </form>

                      3. Avoid naming your submit button "submit." Everyone seems to do it, but
                      they don't realize they're replacing parts of the form object with a form
                      element. This probably has nothing to do with your problem, but it will
                      save you some headaches later if you ever decide to call the
                      formref.submit( ) method explicitly.

                      For now, add another couple of debugging lines like this:
                      alert("Old Value: "+formref.shipp ing_1.value);
                      formref.shippin g_1.value = "12.34";
                      alert("New Value: "+formref.shipp ing_1.value);

                      Also, if your site is hosted on a server running PHP, I have a script that
                      might be useful. It's very simple:

                      <?php
                      echo '<h2>GET Environment</h2><pre>';
                      print_r($_GET);
                      echo '</pre><h2>POST Environment</h2><pre>';
                      print_r($_POST) ;
                      echo '</pre>';
                      ?>

                      If you paste this into a text file, upload it to your site and point any
                      form "action" to this file, it will show you a list of all the information
                      that the form is posting. This might make it easier to debug than
                      submitting it to PayPal every time. If your host isn't running PHP, it's
                      probably running Perl. I can dig out some old code for you that does the
                      same trick, if that's the case.

                      HTH,
                      Zac


                      Comment

                      • Prodoc

                        #12
                        Re: Syntax Help....

                        Zac Hester wrote:
                        [color=blue]
                        > 2. Try one of the many other ways to reference your form and see if that
                        > helps. Try document.forms[document.forms. length-1], document.forms['fred'],
                        > etc. You're doing it right, so I don't have an explanation why this would
                        > work.[/color]

                        Also try document.getEle mentById('formi d').inputtypena me.value='' that's
                        the one I'm always using without any problems.

                        Prodoc

                        Comment

                        • Ross M. Greenberg

                          #13
                          Re: Syntax Help....


                          "Zac Hester" <news@planetzac .net> wrote in message
                          news:3f1f4c41$1 @news.enetis.ne t...[color=blue]
                          >
                          > 1. Never put anything outside of the document. The code you are using to
                          > update this value is after the closing "html" tag. While this should work
                          > for most cases, it's not supposed to according to the basic document type.
                          > All tree structures have to have a root node. In the case of an HTML
                          > document's tree, the root node is the <html></html> element. Nothing can
                          > exist outside of the root. The fact that IE lets us get away with it
                          > doesn't make it right. This could affect the reassignment of this form
                          > value since the "document.f red" object may be out of scope at this point.
                          > Just a theory.[/color]

                          </body>
                          </html>

                          now the last lines in the file. No change.
                          [color=blue]
                          >
                          > 2. Try one of the many other ways to reference your form and see if that
                          > helps. Try document.forms[document.forms. length-1], document.forms['fred'],
                          > etc.[/color]

                          Tried a few different ways. No change.[color=blue]
                          >
                          > 3. Avoid naming your submit button "submit." Everyone seems to do it, but
                          > they don't realize they're replacing parts of the form object with a form
                          > element. This probably has nothing to do with your problem, but it will
                          > save you some headaches later if you ever decide to call the
                          > formref.submit( ) method explicitly.[/color]

                          Renamed. No change.
                          [color=blue]
                          >
                          > For now, add another couple of debugging lines like this:
                          > alert("Old Value: "+formref.shipp ing_1.value);
                          > formref.shippin g_1.value = "12.34";
                          > alert("New Value: "+formref.shipp ing_1.value);[/color]

                          Tried it. Why would I get an "undefined" on the first alert?
                          [color=blue]
                          >
                          > Also, if your site is hosted on a server running PHP, I have a script that
                          > might be useful. It's very simple:[/color]

                          No PHP. Sigh. Script in tester.txt on the site.
                          [color=blue]
                          > If your host isn't running PHP, it's
                          > probably running Perl. I can dig out some old code for you that does the
                          > same trick, if that's the case.[/color]

                          Ross

                          Comment

                          • Philip Ronan

                            #14
                            Re: Syntax Help....

                            I found a couple more errors:

                            1. You've put an onsubmit() handler in the tag for the submit button (it
                            doesn't belong here, and there's another one on the FORM tag anyway)

                            2. Instead of <FORM ... onsubmit="click it()">, try <FORM ...
                            onsubmit="retur n clickit()">

                            I don't know if that's why you're having problems, but see what happens
                            anyway.

                            Phil

                            --
                            Philip Ronan
                            phil.ronanzzz@v irgin.net
                            (Please remove the "z"s if replying by email)


                            Comment

                            • Ross M. Greenberg

                              #15
                              Re: Syntax Help....

                              [color=blue]
                              >
                              > 1. You've put an onsubmit() handler in the tag for the submit button (it
                              > doesn't belong here, and there's another one on the FORM tag anyway)[/color]

                              Just in the FORM now. No diff.
                              [color=blue]
                              >
                              > 2. Instead of <FORM ... onsubmit="click it()">, try <FORM ...
                              > onsubmit="retur n clickit()">
                              >[/color]

                              Done.No diff. I'm going nuts.

                              Comment

                              Working...