• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Runtime Error in JavaScript

 
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 triple checked form and I see that it should be 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=" Add ">
<input type="button" onClick="addLocalScript('DEL')" value="Remove">
</form>

Thanks,
Joel

[This message has been edited by Joel Cochran (edited August 08, 2001).]
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe triggering from the form submission is cleaner and more reliable.
<form name="frmName" onsubmit="return validatedForm();">
Then you return true or false if the form elements check out. This also gives you a great opportunity to change the state of the submitted elements, or point the user to fields that are invalid. Just my .02
 
Joel Cochran
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree, and I use this approach whenever I can. The problem is that in this case I need to know which button was pressed, so I have to do it from the onClick.
I got this resolved late last night, I should have posted to let anyone know, sorry
The problem was the form was being generated from within a loop in a cgi program, so at the end it ended up with over 30 copies of the same form, so I think it just got confused. After changing the CGI program to act differently it worked fine.
Thanks!
------------------
I'm a soldier in the NetScape Wars...
Joel
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many a tricky problem has been resolved in the wee-hours of the morning.
 
We're being followed by intergalactic spies! Quick! Take this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic