The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> JavaScript Development
|
Error in JavaScript
Discuss Error in JavaScript in the JavaScript Development forum on Dev Shed. Error in JavaScript JavaScript Development forum discussing JavaScript and DHTML, AJAX, and issues such as coding cross-browser JavaScript.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

August 8th, 2001, 02:44 PM
|
|
Contributing User
|
|
Join Date: Dec 2000
Posts: 34
Time spent in forums: < 1 sec
Reputation Power: 13
|
|
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=" Add ">
<input type="button" onClick="addLocalScript('DEL')" value="Remove">
</form>
Thanks,
Joel
|

August 8th, 2001, 03:36 PM
|
|
Contributing User
|
|
Join Date: Mar 2001
Location: Dublin
Posts: 413
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.
|

August 8th, 2001, 03:41 PM
|
|
Contributing User
|
|
Join Date: Dec 2000
Posts: 34
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
|

August 8th, 2001, 03:45 PM
|
|
Contributing User
|
|
Join Date: Apr 2001
Location: New York
Posts: 122
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.
|

August 8th, 2001, 03:46 PM
|
|
Contributing User
|
|
Join Date: Mar 2001
Location: Dublin
Posts: 413
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"
|

August 8th, 2001, 03:48 PM
|
|
Contributing User
|
|
Join Date: Mar 2001
Location: Dublin
Posts: 413
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.
|

August 8th, 2001, 04:10 PM
|
|
Contributing User
|
|
Join Date: Dec 2000
Posts: 34
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
|

August 8th, 2001, 04:33 PM
|
|
Contributing User
|
|
Join Date: Dec 2000
Posts: 34
Time spent in forums: < 1 sec
Reputation Power: 13
|
|
That was it!
Yep! Sure enough that was it... the Script was getting confused...
Thanks epl, you are an Inspiration 
|

August 8th, 2001, 05:16 PM
|
|
Contributing User
|
|
Join Date: Mar 2001
Location: Dublin
Posts: 413
Time spent in forums: 2 h 18 m 18 sec
Reputation Power: 13
|
|
Joel,
Delighted to hear that!!
Glad to be of some help,
Ed.
<time for bed now >
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|