submitting form with javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amithoptima3851
    New Member
    • Sep 2007
    • 2

    submitting form with javascript

    [code=asp]<script language="javas cript">
    function log_Varify()
    {
    if(document.frm _index.txt_id.v alue=="")
    {
    alert("Enter your Login Id")
    frm_index.txt_i d.focus()
    }
    else if(document.frm _index.txt_pwd. value=="")
    {
    alert("Enter your Password")
    frm_index.txt_p wd.focus()
    }
    else
    {
    frm_index.metho d="post"
    frm_index.actio n="Login_amit.a sp?mode=login"
    frm_index.submi t()
    }

    }
    </script>

    <%
    if(request.quer yString("mode") ="login") then
    logId=Request.F orm("txt_id")
    pass=Request.Fo rm("txt_pwd")
    Dim conn, rs
    strconn = "DRIVER={SQ L Server};SERVER= 127.0.0.1; DATABASE=sql175 29_db_shoppersm anual;UID=ad175 29; PWD=shoppers"
    set rs=Server.Creat eObject("ADODB. Recordset")
    str="prc_userlo gin '"&logId&"','"& pass&"' "
    'select * from userlogin where userId = '"'&logId&'" and password= '"'&pass&'"
    rs.Open str,strconn
    if(not rs.EOF) then
    Response.Cookie s("Usrlgn")=log Id
    Response.Cookie s("Pass")=pas s
    response.redire ct("index.asp" )
    else
    rs.Close
    Response.write "<strong><f ont color='#FF0000' size='2' face='Verdana, Arial, Helvetica, sans-serif'>Invalid User </font>"
    end if
    end if
    %>[/code]

    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....
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    Hi, and welcome to the scripts developer network. I changed the thread title to make more sense and hopefully get a better response. I also put your code within code tags which makes it easier to read. Please do this yourself in the future.

    In regards to your question, you say the javascript form validation works, but the form is not actually submitted? The code looks OK to me but I'm not a javascript expert, so I'm not sure what the problem is. Are you getting any kind of javascript error on this page?

    Jared

    Comment

    • ilearneditonline
      Recognized Expert New Member
      • Jul 2007
      • 130

      #3
      I am far from a javascript expert and would not even rate myself at intermediate. But whenever I reference a form element, I always do..

      [code=javascript]
      document.frm_in dex.method="pos t";
      document.frm_in dex.action="Log in_amit.asp?mod e=login";
      document.frm_in dex.submit();

      // not
      // frm_index.metho d="post"
      [/code]

      I don't know if it actually makes a difference though. And I always use id fields as well and do document.getEle mentById() to get/set the values.

      Comment

      • markrawlingson
        Recognized Expert Contributor
        • Aug 2007
        • 346

        #4
        This javascript code is completely fine - there is nothing wrong with it. I ran it and was able to submit the form without a hitch.

        Comment

        • syamas
          New Member
          • Sep 2007
          • 10

          #5
          Originally posted by amithoptima3851
          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....

          hello friend
          The changes I think is given below
          Code:
                          document.frm_index.method="post" 
          	document.frm_index.action="Login_amit.asp?mode=login"
          	document.frm_index.submit()
          calling did you do as below ?[html]
          <input type="button" name="Button" value="Submit" onClick=log_Ver ify()>[/html]
          Last edited by jhardman; Sep 6 '07, 03:03 PM. Reason: removed link, put code in code tags

          Comment

          Working...