sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
amithoptima3851's Avatar

submit form data with javascript


Question posted by: amithoptima3851 (Newbie) on September 4th, 2007 07:34 AM
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. %>

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....
2 Answers Posted
dmjpro's Avatar
dmjpro September 4th, 2007 07:45 AM
Lives Here - 2,141 Posts
#2: Re: submit form data with javascript

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>


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. %>


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()


And Best of Luck with your Code.

Kind regards,
Dmjpro.
gits's Avatar
gits September 4th, 2007 07:51 AM
Moderator - 3,360 Posts
#3: Re: submit form data with javascript

hi ...

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

kind regards
MOD
Reply
Not the answer you were looking for? Post your question . . .
196,941 members ready to help you find a solution.
Join Bytes.com

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 196,941 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Javascript / DHTML / Ajax Contributors