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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form submit function not working

Status
Not open for further replies.

mookie0001

Technical User
Jun 14, 2002
23
US
This function is failing to submit the form after the confirmation is accepted. If anyone can point me in the right direction I would greatly appreciate it.

Here is the called JavaScript function:
function confirmEquipAdd() {
var cnfrm = confirm("Are you sure you wish to associate this equipment with selected user?", 4, 3);
if(cnfrm == true) {
document.PCForm.submit();
}
}


Here is the form is in:
<form method=&quot;post&quot; action=&quot;../Inventory_Admin/DBUpdate.asp&quot; id=PCForm name=PCForm>


Here is the first part of the select box calling the function:
<select name=&quot;login&quot; id=&quot;login&quot; onchange=&quot;confirmEquipAdd();&quot;>
 
I tested it jsut like this and it works fine here. What browser are you using?
<html>
<script>
function confirmEquipAdd() {
var cnfrm = confirm(&quot;Are you sure you wish to associate this equipment with selected user?&quot;, 4, 3);
if(cnfrm == true) {
document.PCForm.submit();
}
}
</script>
</head>
<body>

Here is the form is in:
<form method=&quot;post&quot; action=&quot;../Inventory_Admin/DBUpdate.asp&quot; id=&quot;PCForm&quot; name=&quot;PCForm&quot;>


Here is the first part of the select box calling the function:
<select name=&quot;login&quot; id=&quot;login&quot; onchange=&quot;confirmEquipAdd();&quot;>
<option>blah
<option>blah
<option>blah
<option>blah
<option>blah
</select>
</body>
</html> You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
The browser is the newest IE. The error I recieve is &quot;Object doesn't support this property or method&quot;.
 
it may be the &quot; &quot; in the form tag. see how I put the name and id in &quot; &quot;
<form method=&quot;post&quot; action=&quot;../Inventory_Admin/DBUpdate.asp&quot; id=&quot;PCForm&quot; name=&quot;PCForm&quot;>

it may not be recognising the document.PCForm.submit();
because the name is not in quotes

worth a try You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
No luck with the quotes. Here is my exact code (the relevant stuff at least):

<script language=&quot;javascript&quot;>
//-----Display Warning Before Deleting Inventory Record-----
function DeleteWarning() {
var answer = confirm(&quot;This action will completely remove any reference of this item from the database! Are you sure you wish to continue?&quot;, 4, 3);
return(answer);
}
function confirmEquipAdd() {
var cnfrm = confirm(&quot;Are you sure you wish to associate this equipment with selected user?&quot;, 4, 3);
if(cnfrm == true) {
document.PCForm.submit()
}
}
</script>
<html>
<head>
<title>
Inventory Report Page
</title>
</head>
<body leftmargin=&quot;0&quot; topmargin=&quot;0&quot; vlink=&quot;white&quot; alink=&quot;white&quot; link=&quot;white&quot; onload=&quot;document.Search.SUser.focus()&quot;>


<select name=&quot;login&quot; id=&quot;login&quot; onchange=&quot;confirmEquipAdd();&quot;>
<option selected value=&quot;(none)&quot;>(none)</option>
<option value=6>NSOEXL2</option>
<option value=8>NSOKXE1</option>
<option value=10>NSOLMB1</option>
<option value=11>NSOSXD1</option>
<option value=13>TAPARR1</option>
<option value=14>TAPARS1</option>
</select>
</body>
</html>
 
I've noticed difficulties in javascript name resolution when you have declared both a name and an id, try with just name and just id to see if either of those work, if not, remove the document. from your document.PCForm.submit() and try both again. Generally when this happens to me I get it qworking, but it'salways blind luck and I soonn forget what I did.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
take this line out
onload=&quot;document.Search.SUser.focus()&quot;
and see if it gets rid of the error. Is this a form field? This is the only thing I see that may be causing the error You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
I've tried both of your suggestion of using only an id and then only the name, as well as removing the document.Search.SUser.focus(). Still I receive the same error. Another note, the script is being reached, however after the user confirms the error occurs.

And onpnt, you are correct about this being a form field, the form tags are listed a few posts above. I just didn't want to post everything at once because it is some pretty hefty code.

Any other suggestions?
 
I just tried it in IE6, your first example worked for me just fine. Perhaps it is something else in your code?
-tarwm ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
I also cannot duplicate the error you are getting. In IE5 and IE6. What line is the error refering too? You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
Is there some other way I can go about this confirmation? Using this [onchange=&quot;&quot;javascript:this.form.submit();&quot;&quot;>&quot;] instead causes the form to submit just as I need, but without the confirmation. Is there anyway to have two onchange actions (a confirm and then a submit)at once without using a function?
 
To clarify that code, the extra quotes are from the ASP, the client-side change looks like this:

onchange=&quot;javascript:this.form.submit();&quot;
 
Found a solution. There was a second form with the same name that I hadn't noticed which was causing problems. Thanks for all of your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top