#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Posts
    34
    Rep Power
    15

    Unhappy Error in JavaScript


    Hello,

    I have a fairly standard JavaScript that I use frequently to change parameter values in a Form before submitting. This has worked for me countless times before, but I'm getting an error on one form. I have checked everything I can think of to no avail.

    The Error I'm getting says that 'document.addLocal.PROCESS' is null or is not an object. I've highlighted the line in Red, so I know it is an object. And it is not Null, but it's value is blank. Again, I follow this model frequently and have never had a problem before.

    Here is the Script:

    <script language="JavaScript">
    <!--
    function addLocalScript(inLocal) {
    document.addLocal.PROCESS.value = inLocal;
    document.addLocal.submit();
    }
    //-->
    </script>


    And here is the <form>:

    <form name="addLocal" method="post" action="/members/ADDLOCAL">
    <input type="hidden" name="STATS" value="sx3fghyju">
    <input type="hidden" name="SESSION" value="jsmasi">
    <input type="hidden" name="AUTHCODE" value="*AUTH">
    <input type="hidden" name="CLIENTID" value=" ">

    <select name="USERCODE">
    <option value=" "></option>
    <option value="AUG">Augusta County</option>
    <option value="BRS">City of Bristol, VA</option>
    <option value="BUE">City of Buena Vista</option>
    <option value="FLU">Fluvanna County</option>
    <option value="FRD">Frederick County</option>
    <option value="GIL">Giles County</option>
    <option value="LEX">City of Lexington</option>
    <option value="MAD">Madison County</option>
    <option value="SHA">Demonstration Locality</option>
    <option value="SHE">Shenandoah County</option>
    <option value="SMY">Smyth County</option>
    </select>


    <input type="hidden" name="PROCESS" value=" ">

    <input type="button" onClick="addLocalScript('ADD')" value="&nbsp;Add&nbsp;">
    <input type="button" onClick="addLocalScript('DEL')" value="Remove">

    </form>


    Thanks,
    Joel
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Dublin
    Posts
    413
    Rep Power
    14
    This doesn't explain your problem, but it will get you around it.
    Just change the type of your buttons to submit buttons, remove the onclick and name them PROCESS. You can then remove your hidden process field.
    As follows:
    Code:
    <html> 
     <head> 
      <title>Two submit buttons</title>
     </head> 
     <body bgcolor=yellow> 
      <h2>Two submit buttons</h2><hr>
      <form name=addLocal method=post action=/members/ADDLOCAL> 
       <input type=hidden name=STATS value=sx3fghyju> 
       <input type=hidden name=SESSION value=jsmasi> 
       <input type=hidden name=AUTHCODE value=*AUTH> 
       <input type=hidden name=CLIENTID> 
       <select name=USERCODE> 
        <option value= ></option> 
        <option value=AUG>Augusta County</option> 
        <option value=BRS>City of Bristol, VA</option> 
        <option value=BUE>City of Buena Vista</option> 
        <option value=FLU>Fluvanna County</option> 
        <option value=FRD>Frederick County</option> 
        <option value=GIL>Giles County</option> 
        <option value=LEX>City of Lexington</option> 
        <option value=MAD>Madison County</option> 
        <option value=SHA>Demonstration Locality</option> 
        <option value=SHE>Shenandoah County</option> 
        <option value=SMY>Smyth County</option> 
       </select> 
       <input type=submit name=PROCESS value=" Add "> 
       <input type=submit name=PROCESS value="Remove"> 
     </body> 
    </html>
    Last edited by epl; August 8th, 2001 at 04:38 PM.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Posts
    34
    Rep Power
    15

    Parameter Value?


    Thanks epl, but what will the parameter value of PROCESS be in the receiving program?

    I found another error like this but it was because the field name in the script was spelled wrong, but I've checked that as well as the case in both places. I'm just getting frustrated with this problem.

    Thanks again,

    Joel
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Location
    New York
    Posts
    122
    Rep Power
    14
    Wish I could help, but I cut and paste your code and could not reproduce the error. In case you're interested, I've included the code I used:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>test</title>
    <script language="JavaScript">
    <!--
    function addLocalScript(inLocal) {
    document.addLocal.PROCESS.value = inLocal;
    document.addLocal.submit();
    }
    //-->
    </script>
    </head>
    <body>
    <form name="addLocal" method="post" action="/members/ADDLOCAL">
    <input type="hidden" name="STATS" value="sx3fghyju">
    <input type="hidden" name="SESSION" value="jsmasi">
    <input type="hidden" name="AUTHCODE" value="*AUTH">
    <input type="hidden" name="CLIENTID" value="">

    <select name="USERCODE">
    <option value=" "></option>
    <option value="AUG">Augusta County</option>
    <option value="BRS">City of Bristol, VA</option>
    <option value="BUE">City of Buena Vista</option>
    <option value="FLU">Fluvanna County</option>
    <option value="FRD">Frederick County</option>
    <option value="GIL">Giles County</option>
    <option value="LEX">City of Lexington</option>
    <option value="MAD">Madison County</option>
    <option value="SHA">Demonstration Locality</option>
    <option value="SHE">Shenandoah County</option>
    <option value="SMY">Smyth County</option>
    </select>


    <input type="hidden" name="PROCESS" value="">
    <input type="button" onClick="addLocalScript('ADD')" value="Add">
    <input type="button" onClick="addLocalScript('DEL')" value="Remove">
    </form>
    </body>
    </html>


    Good luck.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Dublin
    Posts
    413
    Rep Power
    14
    PROCESS will be set to the value of the submitting button - as intended by your script, I think...
    ie if the user clicks on " Add " then the data sent will include PROCESS as =" Add " etc.
    I suppose that you'd then have to modify the server bit to expect " Add " / "Remove" instead of "Add" / "DEL"
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Dublin
    Posts
    413
    Rep Power
    14
    what's your browser?
    maybe you could try using full titles - eg:
    self.document.forms.addLocal.elements.PROCESS.value = inLocal
    or,
    self.document.forms["addLocal"].elements["PROCESS"].value = inLocal
    in case there is a naming conflict with something else within your page (although it doesn't sound like it)
    Last edited by epl; August 8th, 2001 at 05:19 PM.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Posts
    34
    Rep Power
    15

    Might have found it...


    I was thinking over epl's last post and I think I found it.

    I did a find on the source for the form name to see if there was a conflict, and what I found (and should have realized but it has been one of THOSE days) is that the script AND the form are getting generated from a cgi program... inside a loop...

    The result was about 25 'copies' of each. I'm going to rework the cgi and see if I can't get around that, I'm sure it will do the trick.

    Thanks for everyone's attention.

    Joel
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Posts
    34
    Rep Power
    15

    Talking That was it!


    Yep! Sure enough that was it... the Script was getting confused...

    Thanks epl, you are an Inspiration
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Dublin
    Posts
    413
    Rep Power
    14

    Talking


    Joel,
    Delighted to hear that!!
    Glad to be of some help,
    Ed.
    <time for bed now >

IMN logo majestic logo threadwatch logo seochat tools logo