This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes form submit not working! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "form submit not working!" Watch "form submit not working!" New topic
Author

form submit not working!

Gul Khan
Ranch Hand

Joined: Sep 03, 2003
Posts: 173
Hi all
here is my code in the page when i execute the pade it gives me the following error
"Object does not support the property or method"
function doLogin(){
var id= loginForm.UID.value;

if(id.length > 0 && id.charAt(0)!=" "){
<% request.setAttribute("action","checkUser"); %>
document.loginForm.submit();
}else{
alert("Enter User Name");

}
}

It works fine if i remove the submit line!! I am using a type Button rather than type Submit....
Can someone plz tell me whats wrong with this code.
Thanks
Gul Khan
Ranch Hand

Joined: Sep 03, 2003
Posts: 173
Also the
<% request.setAttribute(..) %> is getting null in the submit servlet while
<% session.setAttribute(..) %> is working fine.
What can be the reason for that.
I Really appreciate any help so i can sleep in peace
Gul
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

what is the name you gave your button? A mistake I made constantly when starting with JavaScript was calling the submit button (or any button) name="submit"
If you do that, document.form.submit() refers to the button and not the submit fnction. You've overwritten it. Not always the best practice, but in JavaScript I tend to call buttons btnXXX and I rarely use submit buttons.
Dave
Gul Khan
Ranch Hand

Joined: Sep 03, 2003
Posts: 173
Thanks alot , i changed the name and id of the button and it worked fine.
The only problem with the code remaining is the request variable "action".
If i set the value into the session rather than in request, it works and i can retrieve it in the servlet it is being posted to... But with request i get a null value in the attribute.
Can u plz also help me with that.
Thanks again for the first problem

Gul
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Bit of a problem here: This thread contains both JavaScript and JSP questions. Rather than trying to diagnose and solve the problem here, or move the thread to JSP, can I get you to start a new thread in the JSP forum for the JSP specific part?
Just a bit of book keeping, otherwise we prevent the solutions from helping others who come looking for it.
I'll go looking for your thread there!
thanks,
Dave.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: form submit not working!
 
Similar Threads
onUnload
Radio Select and Other
about unite string
onclick as a replacement for onsubmit
automatic form submit