Syntax Help....

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

    #16
    Re: Syntax Help....

    "Ross M. Greenberg" <greenber-at-catskill.net> wrote in message
    news:vhvh9in3gn lj01@corp.super news.com...[color=blue]
    >
    > "Zac Hester" <news@planetzac .net> wrote in message
    > news:3f1f4c41$1 @news.enetis.ne t...[color=green]
    > >
    > >
    > > 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]

    This is saying something. JavaScript doesn't really care if you make up
    object properties on the fly, so my guess is that you were never assigning
    the value to the form object's property. You are referencing some other
    (new) object. Here's what you can try:

    Copy out your form and JavaScript associated to that form. Put all of your
    JavaScript in the "head" of your document. Here's a quick page I wrote up
    that works on my browser. Try copying this into a new HTML document and see
    what happens.


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>JavaScri pt Form Test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript">
    function update_form(for mref, debug) {
    if(debug) {
    alert('Initial Value: '+formref.shipp ing_1.value);
    }
    formref.shippin g_1.value = "321";
    if(debug) {
    alert('Assigned Value: '+formref.shipp ing_1.value);
    }
    //Keep it from submitting for now.
    return(false);
    }
    </script>
    </head>
    <body>
    <h3>JavaScrip t Form Test</h3>
    <form name="test" id="testid" action="tester. php"
    method="post" onsubmit="retur n update_form(thi s, true);">
    <input type="text" name="shipping_ 1" value="123" />
    <input type="submit" name="submit_bu tton" value="Submit" />
    </form>
    </body>
    </html>



    Hopefully, this is enough that you can take it an add your own form
    elements. Paste the end result into your page and see if it still works.

    Also, I wrote this little function that might be of use:


    function show_form_data( formref) {
    var i, buffer = '';
    for(i = 0; i < formref.element s.length; i++) {
    buffer += formref.element s[i].name
    +': '+formref.eleme nts[i].value+"\n";
    }
    return(confirm( "Form Data about to Be Submitted:\n\n"
    +buffer+"\n\nPr oceed?"));
    }


    If you call this from your form with an onsubmit="retur n
    show_form_data( this);", this will show you a list of all the data in a form.
    [color=blue][color=green]
    > >
    > > Also, if your site is hosted on a server running PHP, I have a script[/color][/color]
    that[color=blue][color=green]
    > > might be useful. It's very simple:[/color]
    >
    > No PHP. Sigh. Script in tester.txt on the site.
    >[/color]

    You'll need to name it tester.php for it to work on a PHP-enabled host.

    Let me know how it turns out,
    Zac


    Comment

    • Ross M. Greenberg

      #17
      Re: Syntax Help....

      Make that a "POST" action. Same thing.

      "Ross M. Greenberg" <greenber-at-catskill.net> wrote in message
      news:vi0b9k13lh oa61@corp.super news.com...[color=blue]
      >[color=green][color=darkred]
      > > >
      > > > No PHP. Sigh. Script in tester.txt on the site.
      > > >[/color]
      > >
      > > You'll need to name it tester.php for it to work on a PHP-enabled host.
      > >[/color]
      >
      > Ah! renaming it to .php works -- and the "12.30" doesn't show up! I've left
      > that in as a "get" action..
      >
      >[/color]

      Comment

      • Ross M. Greenberg

        #18
        Re: Syntax Help....


        [color=blue][color=green]
        > >
        > > Done.No diff. I'm going nuts.
        > >[/color]
        >
        > OK, relax! I'm sure this can't be too difficult to fix.
        >[/color]

        First, thanks for the help! Everybody. I've discovered the problem. Haven't
        fixed it yet. The fix will be trivial, I'm sure.

        Ends up that some JScript executed early in the code reads and remembers all
        the hidden variables and emits them right before it exits. In essence,
        over-writing any hidden variable changes with their original values.

        And I thought the third-party shopping cart was gonna save me time, instead of
        wasting my -- and your -- time.

        Thanks for the efforts, my apologies, and I need to sulk in some single-malt
        Scotch.

        Sigh.

        Ross

        Comment

        Working...