Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form.submit() problems... 1

Status
Not open for further replies.

Edcrosbys

ISP
Apr 26, 1999
112
US
What should be fairly simple script is giving the error "document.form has no properties". Any help would be greatly appreciated!

</code>

<script LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;FormChek.js&quot;></SCRIPT>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!---
function checkJobid(){
var theForm=window.document.doedit;
var theVar=window.document.doedit.jobid.value;
if (isPositiveInteger(theForm.jobid.value))
{
if (theVar.length >= 3)
document.form['doedit'].submit;
else
{
alert(&quot;Please enter a Job ID of 3 or more digits&quot;);
theForm.jobid.focus();
return(false);
}
}
else
{
alert(&quot;Please enter a numeric Job ID &quot;);
theForm.jobid.focus();
return(false);
}
}
//-->
</script>
<form name=&quot;doedit&quot; method=&quot;GET&quot; action=&quot;makechange.asp&quot;>
<many more inputs>
<INPUT TYPE=&quot;button&quot; name=&quot;submit&quot; value=&quot;Submit Changes&quot; onClick=&quot;checkJobid()&quot;>
</code>
 
First off, here's soemthing I do a lot.
Whe I run into errors, I place empty or numbered alert tags into my code, like the following:

function checkJobid(){
var theForm=window.document.doedit;
var theVar=window.document.doedit.jobid.value;
alert(&quot;1&quot;);
if (isPositiveInteger(theForm.jobid.value))
{
alert(&quot;2&quot;);
if (theVar.length >= 3)
alert(&quot;3&quot;);
document.form['doedit'].submit;
alert(&quot;4&quot;);

etc...

This way you can narrow down exactly the area you are having the problem (because it'll occur right after the last alert and right before the one you don't see).


Anyways as to your problem....

1.
var theForm=window.document.doedit;
var theVar=window.document.doedit.jobid.value;
should be
var theForm=document.doedit;
var theVar=document.doedit.jobid.value;
If it's on the same page, there's no need for using the window part.

2.
document.form['doedit'].submit;
should be
document.doedit.submit();

3.
This last issue I had happen to me.
When you make a call to sumbit the form like so:
ment.doedit.submit();

it actually tries to access the input field below which is named &quot;submit&quot;:
<INPUT TYPE=&quot;button&quot; name=&quot;submit&quot; value=&quot;Submit Changes&quot; onClick=&quot;checkJobid()&quot;>

Thus, simply change the name of that imput field to something like &quot;submit1&quot; or anything other than submit.
 
This didn't help. Same errors.

var theVar=window.document.doedit.jobid.value;
and
var theVar=document.doedit.jobid.value;

- They both return the same error:
&quot;document.doedit has no properties.&quot;

I wish I could find the problem!! this is driving me crazy!!

 
u could try to access your form by document.forms[x]
or using &quot;reference object&quot; to your function
like :
function functionname(formobject) {
formobject.childname. //etc ...

and passing the object with 'this'
<form method=&quot;GET&quot; action=&quot;makechange.asp&quot; onsubmit=&quot;checkJobid(this)&quot;>
<many more inputs>
<INPUT TYPE=&quot;button&quot; name=&quot;submit&quot; value=&quot;Submit Changes&quot;>

hope this help ....
---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
Here you go, this code works:
<html>
<head>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!---
function checkJobid(){
var theForm=document.doedit;
var theVar=document.doedit.jobid.value;
if (theVar>0)
{
if (theForm.jobid.length >= 3)
document.doedit.submit();
else
{
alert(&quot;Please enter a Job ID of 3 or more digits&quot;);
theForm.jobid.focus();
return(false);
}
}
else
{
alert(&quot;Please enter a numeric Job ID &quot;);
theForm.jobid.focus();
return(false);
}
}
//-->
</script>
</head>
<body>
<form name=&quot;doedit&quot; method=&quot;GET&quot; action=&quot;makechange.asp&quot;>
<INPUT TYPE=&quot;button&quot; name=&quot;jobid&quot; value=&quot;Submit Changes&quot; onClick=&quot;checkJobid()&quot;>
</form>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top