SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    enter causes submit button to be activated

    I figured out that it is a default feature that if you are in an input box and hit the enter button it will cause the form to sort of 'submit'. I have a page where the form action is the actual page but it does all its variable assigning and such inside of an if then statement.
    If Request.Form("submit")<> Then
    and at the end of the if then I have a response.redirect to throw the results of my variables in the llink.
    So what happens is when I hit the enter button it almost looks like the page is refreshing since the form action is the form itself. And the form doesnt even get into the If then statement. Anyone have any suggestions or direction as to what the easiest way I can do this is? Thanks in advance.

  2. #2
    SitePoint Enthusiast team_ecommerce's Avatar
    Join Date
    Feb 2005
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If your form is submitting to itself then your IF - THEN statement is always executed. Try adding an ELSE clause to your IF-THEN.

    Ex.

    IF Request.Form("submit") <> "" THEN
    reponse.write "DEBUG: form submitted<br>"
    ELSE
    reponse.write "DEBUG: form NOT submitted<br>"
    END IF

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this postback technique...if user hits enter in input box whatever data was entered won't go away...it's stored in the vars....can be used to errorcheck "empty" fields and NOT lose data at the same time too

    <%
    lname = Request.Form("lname")
    %>

    <form>
    <input name="lname" value="<%=lname%>">
    <input type="submit" name="submit" value="Submit">
    </form>


Bookmarks

Posting Permissions

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