Connecting Tech Pros Worldwide Help | Site Map

submit form data with javascript

 
LinkBack Thread Tools Search this Thread
  #1  
Old September 4th, 2007, 06:34 AM
Newbie
 
Join Date: Sep 2007
Posts: 2
Default submit form data with javascript

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2. function log_Varify()
  3. {
  4. if(document.frm_index.txt_id.value=="")
  5. {
  6.     alert("Enter your Login Id")
  7.     frm_index.txt_id.focus()
  8.     }
  9. else if(document.frm_index.txt_pwd.value=="")
  10. {
  11.     alert("Enter your Password")
  12.     frm_index.txt_pwd.focus()
  13. }
  14. else
  15. {
  16.     frm_index.method="post" 
  17.     frm_index.action="Login_amit.asp?mode=login"
  18.     frm_index.submit()
  19. }
  20.  
  21. }
  22. </script>
  23.  
  24. <%             
  25. if(request.queryString("mode")="login") then
  26.     logId=Request.Form("txt_id")
  27.     pass=Request.Form("txt_pwd")
  28.     Dim conn, rs
  29.     strconn = "DRIVER={SQL Server};SERVER=127.0.0.1; DATABASE=sql17529_db_shoppersmanual;UID=ad17529; PWD=shoppers"
  30.     set rs=Server.CreateObject("ADODB.Recordset")
  31.     str="prc_userlogin '"&logId&"','"&pass&"' "
  32.     'select * from userlogin where userId = '"'&logId&'" and password= '"'&pass&'" 
  33.     rs.Open str,strconn    
  34.     if(not rs.EOF) then
  35.         Response.Cookies("Usrlgn")=logId
  36.         Response.Cookies("Pass")=pass
  37.                 response.redirect("index.asp")
  38.     else 
  39.             rs.Close
  40.         Response.write "<strong><font color='#FF0000' size='2' face='Verdana, Arial, Helvetica, sans-serif'>Invalid User </font>"
  41.     end if  
  42. end if
  43. %>
  44.  
Hello All,
This was my javascript+ASP code for login ,onclick of a button(i am calling javascript function)its validating but its not submitting.As far as i know database connections are perfect i used it in another form.

Please help me....

Last edited by gits; September 4th, 2007 at 06:48 AM. Reason: added code tags
Reply
  #2  
Old September 4th, 2007, 06:45 AM
dmjpro's Avatar
Lives Here
 
Join Date: Jan 2007
Location: India (West-Bengal)
Age: 25
Posts: 2,429
Default

Quote:
Originally Posted by amithoptima3851
Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2. function log_Varify()
  3. {
  4. if(document.frm_index.txt_id.value=="")
  5. {
  6.     alert("Enter your Login Id")
  7.     frm_index.txt_id.focus()
  8.     }
  9. else if(document.frm_index.txt_pwd.value=="")
  10. {
  11.     alert("Enter your Password")
  12.     frm_index.txt_pwd.focus()
  13. }
  14. else
  15. {
  16.     frm_index.method="post" 
  17.     frm_index.action="Login_amit.asp?mode=login"
  18.     frm_index.submit()
  19. }
  20.  
  21. }
  22. </script>
  23.  
Expand|Select|Wrap|Line Numbers
  1. <%             
  2. if(request.queryString("mode")="login") then
  3.     logId=Request.Form("txt_id")
  4.     pass=Request.Form("txt_pwd")
  5.     Dim conn, rs
  6.     strconn = "DRIVER={SQL Server};SERVER=127.0.0.1; DATABASE=sql17529_db_shoppersmanual;UID=ad17529; PWD=shoppers"
  7.     set rs=Server.CreateObject("ADODB.Recordset")
  8.     str="prc_userlogin '"&logId&"','"&pass&"' "
  9.     'select * from userlogin where userId = '"'&logId&'" and password= '"'&pass&'" 
  10.     rs.Open str,strconn    
  11.     if(not rs.EOF) then
  12.         Response.Cookies("Usrlgn")=logId
  13.         Response.Cookies("Pass")=pass
  14.                 response.redirect("index.asp")
  15.     else 
  16.             rs.Close
  17.         Response.write "<strong><font color='#FF0000' size='2' face='Verdana, Arial, Helvetica, sans-serif'>Invalid User </font>"
  18.     end if  
  19. end if
  20. %>
  21.  
Hello All,
This was my javascript+ASP code for login ,onclick of a button(i am calling javascript function)its validating but its not submitting.As far as i know database connections are perfect i used it in another form.

Please help me....
Hi amithoptima3851!
You should maintain the Post Guidelines.
Use code Tag.

Use this.
Expand|Select|Wrap|Line Numbers
  1. document.frm_index.method="post" 
  2. document.frm_index.action="Login_amit.asp?mode=login"
  3. document.frm_index.submit()
  4.  
And Best of Luck with your Code.

Kind regards,
Dmjpro.
Reply
  #3  
Old September 4th, 2007, 06:51 AM
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Age: 37
Posts: 3,780
Default

hi ...

changed thread-title to better describe the problem - always use a good thread title

kind regards
MOD
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.