Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

form submit not working!

 
Gul Khan
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic