SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    discriminating how it's coming to action cfm

    Code:
    <form action='action.cfm'>
    
    <input type='text'>
    
    <input type='submit'>
    
    </form>
    With the code above, there are two ways to make it move to action.cfm.

    (1) The one is clicking the buttton "submit."

    (2) The other is striking the enter key after putting your mouse on the input text box.


    I like to discriminate whether it is coming using the button "submit" or striking enter key.

    The following would-be code doesn't correctly, but it will show what I want.

    Code:
    action.cfm
    
    <cfif it's coming by clicking the button "submit.">
    
    It's coming by clicking the button "submit."
    
    <cfelseif it's coming by striking enter key 
    after putting his or her mouse on the input text form>
    
    It's coming by striking the enter key.
    
    
    </cfif>

  2. #2
    SitePoint Wizard jonese's Avatar
    Join Date
    Jul 1999
    Location
    Powder Springs GA (Atlanta)
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i don't know how to do this but my guess is you'll need to use javascript to intercept either the enter key or submit button and then either create a new form variable or update an already hidden variable with something you can use in CF later...

    a quick Google search brought up this URL http://jennifermadden.com/javascript...yDetector.html

  3. #3
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    logic_earth said I should rework it in server-side at http://www.sitepoint.com/forums/show...76#post3197676

  4. #4
    Take The Blue Pill neilmerton's Avatar
    Join Date
    Jul 2004
    Location
    Leicester, UK
    Posts
    871
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what about checking if the form button was clicked - if not then presume that the user simply hit the enter key.

    try the following out:

    HTML Code:
    <cfif isDefined("form.testaction") and isNumeric(form.testaction) and (form.testaction eq 1)>
    
    <cfdump var="#form#" />
    
    <cfelse>
    
    <form action="<cfoutput>#cgi.script_name#</cfoutput>" id="testform" name="testform" method="post">
        <input type="text" id="testfield" name="testfield" value="" />
        <input type="submit" id="testbutton" name="testbutton" value="Click Me" />
        <input type="hidden" id="testaction" name="testaction" value="1" />
    </form>
    
    </cfif>
    when the button is clicked it's displayed in the dump data, if not it's not there!

  5. #5
    minister of propaganda silver trophy Rynoguill's Avatar
    Join Date
    Feb 2004
    Location
    Midsouth
    Posts
    1,373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Neil has it right there. Only by clicking the button does the submit button show, but it also requires that your submit button has a name attribute.

    But like jonese said, you can use javascript if you would rather. Just onclick on the submit button, set the value of a hidden field to something different. Like you could have a hidden field named submitButtonClicked, and set it equal to false by default, and then if the submit button is clicked, change its value right before you submit the form.

    But if you don't know enough javascript, the first method would be the easiest and should work just fine.
    rynoguill
    Ryan Guill, AKA Mark Roman


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
  •