JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 8th, 2001, 02:44 PM
Joel Cochran Joel Cochran is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Posts: 34 Joel Cochran User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
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

Reply With Quote
  #2  
Old August 8th, 2001, 03:36 PM
epl epl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Dublin
Posts: 413 epl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 18 m 18 sec
Reputation Power: 13
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 03:38 PM.

Reply With Quote
  #3  
Old August 8th, 2001, 03:41 PM
Joel Cochran Joel Cochran is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Posts: 34 Joel Cochran User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
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

Reply With Quote
  #4  
Old August 8th, 2001, 03:45 PM
szarecor szarecor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: New York
Posts: 122 szarecor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
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.

Reply With Quote
  #5  
Old August 8th, 2001, 03:46 PM
epl epl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Dublin
Posts: 413 epl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 18 m 18 sec
Reputation Power: 13
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"

Reply With Quote
  #6  
Old August 8th, 2001, 03:48 PM
epl epl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Dublin
Posts: 413 epl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 18 m 18 sec
Reputation Power: 13
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 04:19 PM.

Reply With Quote
  #7  
Old August 8th, 2001, 04:10 PM
Joel Cochran Joel Cochran is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Posts: 34 Joel Cochran User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
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

Reply With Quote
  #8  
Old August 8th, 2001, 04:33 PM
Joel Cochran Joel Cochran is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Posts: 34 Joel Cochran User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
Talking That was it!

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

Thanks epl, you are an Inspiration

Reply With Quote
  #9  
Old August 8th, 2001, 05:16 PM
epl epl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Dublin
Posts: 413 epl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 18 m 18 sec
Reputation Power: 13
Talking

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

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Error in JavaScript

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap