Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: submit button

  1. #1
    Regular Coder
    Join Date
    Jan 2003
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question submit button

    hi
    i have this problem of putting a button which is an image and then giving it the job of submit. i have this loop in my asp code:

    if Request.Form("Submit") = "Submit" then

    and in my body i have my image button which is image.gif

    <input type="Image" value="Submit" src="images/SUBMIT.gif" width="90" height="22">

    i tried this but it doesn't work. does the loop read the input type or the value?

  • #2
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    I think it must be done with javascript.

    Code:
    <form name="myform" action="somewhere.asp" method="get">
    <a onclick="document.myform.submit()" href="#"><img src="image.gif"></a>
    </form>

  • #3
    Regular Coder
    Join Date
    Jan 2003
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts
    but then with this code even the user doesn't put any username and password
    simply clicking on the image button they'll be redirected to the other page.
    is it right or am i thinking wrong?


    know i am clear with my problem...i did make the if loop to read the input type and input type must be "submit " for this loop to run.i need to find a way of keeping the input type"submit" but still be able to use my image button which has the original input type "image".

    Any idea?

  • #4
    New Coder
    Join Date
    Jun 2002
    Location
    Bonny Scotland! Status: Insane
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts
    With that script, the link is acting just like a submit button so any other fields that were in the form would be submitted like normal.
    «Ðå G壣ꮻ²ºº²

  • #5
    Regular Coder
    Join Date
    Jan 2003
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs down

    no i tried it it's not the right way. i should find a way of giving this image button input type "Submit" where its original input type is "image".

    Like i told before with the js u suggested it's not redirecting you to the page besides even without putting username and password it redirects u but not to the actual page i want to a blank page.

    i need to find a way of keeping the input type submit however it is image.

  • #6
    New Coder
    Join Date
    Jun 2002
    Location
    Bonny Scotland! Status: Insane
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you had:
    <form name="myform" action="somewhere.asp" method="get">
    <input type="text" name="username">
    <input type="text" name="password">
    <a onclick="document.myform.submit()" href="#"><img src="image.gif"></a>
    </form>

    & your "somewhere.asp" checked if the username & password were entered, then could you not play around with it & do whatever you want with it from there?

    Maybe I just dont know what u want.
    Gaffer
    «Ðå G壣ꮻ²ºº²

  • #7
    Regular Coder
    Join Date
    Jan 2003
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <%@ Language = "VBScript"%>
    <%


    'Declare all local variables
    dim conn
    dim rs
    dim strconn
    dim strSQL
    Dim strUserName
    Dim strPassword


    if Request.Form("Submit") = "Submit" then

    strUserName = Request.Form("username")
    strPassword = Request.Form("password")

    Set conn = Server.CreateObject("ADODB.Connection")
    Set rs= Server.CreateObject("ADODB.RecordSet")
    'set connection string to local variable-I use a DSN-less connection
    'Need to modify just this line.Point to right path to database file.
    conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("\anticus\db\Book Details.mdb"))
    'build the sql statement based on the input from the form
    strSQL = "SELECT * FROM Users WHERE UserName='" & strUserName & "' AND Password='" & strPassword & "'"
    rs.open strSQL, conn


    'Use the execute method of the connection object the insert the record
    'conn.execute(strSQL)

    if rs.eof or rs.bof then
    Response.Write("<center><font color='red'>Invalid Username or Password</font></center>")
    else
    Session("UserName") = strUserName
    Response.Redirect "Control.asp?qUserName=" & strUserName
    end if

    rs.close
    conn.close
    set conn = nothing

    end if

    %>

    <body>
    <form action="introduction.asp" method="post" name="IntroductionForm">

    <div id="Layer4" style="position:absolute; left:571px; top:396px; width:86px; height:19px; z-index:4">
    <input type="text" name="username">
    </div>
    <div id="Layer6" style="position:absolute; left:571px; top:431px; width:144px; height:21px; z-index:6">
    <input type="password" name="password">
    <div id="Layer8" style="position:absolute; left:275px; top:561px; width:90px; height:16px; z-index:8"> <a onclick="document.IntroductionForm.submit()" href="control.asp"><img src="images/SUBMIT.gif" width="90" height="22"></div>


    this is my code.so do u think that way still works?

  • #8
    New Coder
    Join Date
    Jun 2002
    Location
    Bonny Scotland! Status: Insane
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if introduction.asp is the page your already on, that should work...
    «Ðå G壣ꮻ²ºº²

  • #9
    Regular Coder
    Join Date
    Jan 2003
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts
    my redirection is already in ASP code so i think that's not the way u suggessted is working.

    i am not really professional in ASP these are my first tries. so if i delete the redirection bit in ASP part do u think it'll work?

  • #10
    New Coder
    Join Date
    Jun 2002
    Location
    Bonny Scotland! Status: Insane
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, if you were wanting 2 log in the user using that same page, the form would have to be going back to the page that your on. (eg. ur page should be called introduction.asp)
    Then I would take out the If Request.Form("submit") blah blah & put in something like
    If Len(username) > 0 & Len(password) > 0 Then
    Then the redirect should take you to where ever you want them to end up.
    «Ðå G壣ꮻ²ºº²

  • #11
    Regular Coder
    Join Date
    Jan 2003
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well actually th user registers at registration page this introduction page is for existing users to log on. if they don't have a username and password then first they get it by clicking the link on introduction page.

    so in this case the page is just for logging in not registering.
    do u think that way u suggested is still valid?

  • #12
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    edit: after reading through the thread, I am way off. You can probably ignore this post.

    <input type="image"> triggers the onsubmit() event so you can use it directly as a submit button. Is this similar to what you need?

    Code:
    <html>
    <head>
    <script language="javascript">
    function validate(theform){
    var error_msg="";
     if (theform.uname.value=="")
      error_msg="enter a username\n";
     if (theform.pwd.value=="")
      error_msg+=error_msg="enter a password\n";
    
     if (error_msg=="")
      return true
     else{
      alert('You have errors\n'+error_msg)
      return false;
     }
    }
    </script>
    </head> 
    <body>
    <form name="myform" action="somewhere.asp" method="get" onsubmit="return validate(this);">
    <input type="text" name="uname"><br>
    <input type="password" name="pwd"><br>
    <input type="image" name="point" src="map.gif">
    </form>
    </body> 
    </html>
    Last edited by arnyinc; 01-17-2003 at 10:45 PM.

  • #13
    New Coder
    Join Date
    Jun 2002
    Location
    Bonny Scotland! Status: Insane
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would think so, I saw that that was a login page, so the way i described should work. So long as the form is submitting itself to the page its on, then it should work.
    «Ðå G壣ꮻ²ºº²

  • #14
    Regular Coder
    Join Date
    Jan 2003
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well yeah but it has some differences as well

    because in this js it just checks if the user has out a username or password else it gives errors.

    there should be another option like if the user name and password is equal to the one that they entered the first time they registered then the user should be redirected to another page.

    so can i add another if

    where it cheks that the password and the username is one of those staying in database from the first time users has registered?
    this is sort of mixing the asp with javascript.

    if yes how can i do it?

  • #15
    New Coder
    Join Date
    Jun 2002
    Location
    Bonny Scotland! Status: Insane
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You shouldn't need Javascript to check if the username & password exists as ASP does this for you. That javascript would really be unneccisery
    «Ðå G壣ꮻ²ºº²


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •