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.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Aug 2003
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Help: Click button, set contents, then submit

    Hi,
    Can anyone help me - this is fairly simple but I'm not good with syntax yet... I have a regular button that, when clicked, should set the contents of a search text field called "keywords" to the string "sold", and then click the associated submit button. Not sure where to add the code to get it to submit, and also the "sold" isn't even going into the field. I'd like to do this invisibly, but don't know how. Please help me? Thank you Mary

    <input type="button" onClick="document.srch.keywords.value="sold" name="search_request_button" value="Search Our Sold Properties" >
    Last edited by pa2stepper; 10-20-2003 at 10:21 PM.

  • #2
    Regular Coder
    Join Date
    Jul 2003
    Location
    NJ - #29 if you must know
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    First, you have quotes within quotes.

    onClick="document.srch.keywords.value="sold"
    to:
    onClick="document.srch.keywords.value='sold';FORMNAME.submit();"

    George

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <input type="button" onClick="this.form.keywords.value='sold';this.form.submit();" name="search_request_button" value="Search Our Sold Properties" >

    This should work, your original had mismatched quote marks and needed the submit call. I abstracted the reference to the containing form so it won't haurt the code if the name of the form is changed and the original reference was using an IE proprietary reference to the form while the changed reference to the form should work with all browsers.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #4
    New Coder
    Join Date
    Aug 2003
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    YAY!!!!! IT WORKED!!!!!

    You are the greatest!!!!!!!!!!!!!!!!! Thanks so much!!!!!!!

  • #5
    New Coder
    Join Date
    Aug 2003
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    It worked! Thx!! One final question...

    This code worked beautifully!!! Is it outside the scope of Javascript to avoid showing the word "sold" as it populates the search field - in other words, to make it invisible somehow since they are just clicking a button? Yes? Yes?

    <input type="button" onClick="this.form.keywords.value='sold';this.form.submit();" name="search_request_button" value="View Recently Sold Properties" >

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,045
    Thanks
    0
    Thanked 251 Times in 247 Posts
    If you don't want to show the field keywords, then why not make it hidden?

    <input type="hidden" name="keywords">


  •  

    Posting Permissions

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