Search button

Discussion in 'HTML' started by Shelly, Nov 30, 2007.

  1. Shelly

    Shelly Guest

    I know this must be simple, but I need a little help as this isn't my area.
    I have a search box called searchText and a search button called
    searchButton. If a user puts "foo" in the text box and clicks the search
    button, I want this to change pages with "foo" as a parameter. Sort of go
    to "_the_new_page?param=foo" from the onclick command. How do I construct
    that such that it forms that string and does a window.location with that
    string? I looked over the web, but didn't find clear examples.
     
    Shelly, Nov 30, 2007
    #1
    1. Advertising

  2. Shelly

    BootNic Guest

    "Shelly" <> wrote:
    news::

    > I know this must be simple, but I need a little help as this isn't my
    > area. I have a search box called searchText and a search button called
    > searchButton. If a user puts "foo" in the text box and clicks the
    > search button, I want this to change pages with "foo" as a parameter.
    > Sort of go to "_the_new_page?param=foo" from the onclick command. How
    > do I construct that such that it forms that string and does a
    > window.location with that string? I looked over the web, but didn't
    > find clear examples.


    <form action="/_the_new_page" action="get">
    <div>
    <label for="t1">search item </label>
    <input type="text" id="t1" name="param">
    </div>
    <div>
    <input type="submit" value="searchButton">
    </div>
    </form>

    --
    BootNic Friday November 30, 2007 12:32 AM
    "So tell me, just how long have you had this feeling that no one is
    watching you?"
    *Christopher Locke: Entropy Gradient Reversals*
     
    BootNic, Nov 30, 2007
    #2
    1. Advertising

  3. Shelly

    BootNic Guest

    BootNic <> wrote: news:Xns99F85784EC4CBootNic@
    85.214.90.236:

    > "Shelly" <> wrote:
    > news::
    >
    >> I know this must be simple, but I need a little help as this isn't my
    >> area. I have a search box called searchText and a search button called
    >> searchButton. If a user puts "foo" in the text box and clicks the
    >> search button, I want this to change pages with "foo" as a parameter.
    >> Sort of go to "_the_new_page?param=foo" from the onclick command. How
    >> do I construct that such that it forms that string and does a
    >> window.location with that string? I looked over the web, but didn't
    >> find clear examples.

    >
    > <form action="/_the_new_page" action="get">


    That second action should have been method.

    <form action="/_the_new_page" method="get">

    [snip]

    --
    BootNic Friday November 30, 2007 1:13 AM
    A person without a sense of humor is like a wagon without springs,
    jolted by every pebble in the road.
    *Henry Ward Beecher*
     
    BootNic, Nov 30, 2007
    #3
  4. Shelly

    Shelly Guest

    BootNic wrote:
    > BootNic <> wrote: news:Xns99F85784EC4CBootNic@
    > 85.214.90.236:
    >
    >> "Shelly" <> wrote:
    >> news::
    >>
    >>> I know this must be simple, but I need a little help as this isn't
    >>> my area. I have a search box called searchText and a search button
    >>> called searchButton. If a user puts "foo" in the text box and
    >>> clicks the search button, I want this to change pages with "foo" as
    >>> a parameter. Sort of go to "_the_new_page?param=foo" from the
    >>> onclick command. How do I construct that such that it forms that
    >>> string and does a window.location with that string? I looked over
    >>> the web, but didn't find clear examples.

    >>
    >> <form action="/_the_new_page" action="get">

    >
    > That second action should have been method.
    >
    > <form action="/_the_new_page" method="get">
    >
    > [snip]


    I need the resulting string that appears on the target page to be:

    _the_target_page?type=blah&keyword=foo

    I could make the name of the input text field be keyword. What would the
    action look like? Would it be

    "_the_target_page?type=blah" ?

    Would I rather just need to define a hidden field and give it the name
    "type" and the value "blah" ?

    If this is the case, then I am left with the single problem of the not
    having an input button of type submit, but having an image instead.

    Shelly
     
    Shelly, Nov 30, 2007
    #4
  5. Shelly wrote:

    > Would I rather just need to define a hidden field and give it the name
    > "type" and the value "blah" ?


    Yep. That's certainly the easiest way.

    > If this is the case, then I am left with the single problem of the not
    > having an input button of type submit, but having an image instead.


    <input type=image src="foo.png" alt="Submit Your Foo Query">

    If you give that input a name, then the browser should also add x,y co-
    ordinates for the pixel that the user clicked on to the resultant URL.
    Sometimes that's useful. Most of the time it's not.

    --
    Toby A Inkster BSc (Hons) ARCS
    [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
    [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 5 days, 19:25.]

    Sharing Music with Apple iTunes
    http://tobyinkster.co.uk/blog/2007/11/28/itunes-sharing/
     
    Toby A Inkster, Nov 30, 2007
    #5
  6. Scripsit Toby A Inkster:

    > Shelly wrote:

    - -
    >> If this is the case, then I am left with the single problem of the
    >> not having an input button of type submit, but having an image
    >> instead.


    Huh? _What_ is the problem? If the problem is that you don't have a
    normal submit button, get one. ;-) If not, make sure that you are
    solving a problem and not creasting one.

    > <input type=image src="foo.png" alt="Submit Your Foo Query">


    Well, the alt text is too long. The button text should seldom be longer
    than one or two words, like "Submit query". And you should also have the
    name="Submit query" and value="Submit query", for user agents that use
    _them_ and not the alt attribute as fallback.

    > If you give that input a name, then the browser should also add x,y
    > co- ordinates for the pixel that the user clicked on to the resultant
    > URL. Sometimes that's useful. Most of the time it's not.


    The coordinates are not included unless there is a name="..." attribute.

    But image submit buttons are almost always a bad idea. They are mostly
    used for esthetic reasons, but I don't think I've _ever_ seen such a
    button that looks better than, say, the default rendering of submit
    buttons on XP or Vista. I might say that _some_ of them were a slight
    improvement over the "ugly gray buttons" in stone-age browsers that are
    mostly used by freaks these days.

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Nov 30, 2007
    #6
  7. Shelly

    Shelly Guest

    Toby A Inkster wrote:
    > Shelly wrote:
    >
    >> Would I rather just need to define a hidden field and give it the
    >> name "type" and the value "blah" ?

    >
    > Yep. That's certainly the easiest way.
    >
    >> If this is the case, then I am left with the single problem of the
    >> not having an input button of type submit, but having an image
    >> instead.

    >
    > <input type=image src="foo.png" alt="Submit Your Foo Query">
    >
    > If you give that input a name, then the browser should also add x,y
    > co- ordinates for the pixel that the user clicked on to the resultant
    > URL. Sometimes that's useful. Most of the time it's not.


    Thank you very much. That worked like a charm. The hidden fields were
    necessary.

    --
    Shelly
     
    Shelly, Nov 30, 2007
    #7
  8. Jukka K. Korpela wrote:
    > Scripsit Toby A Inkster:
    >
    >> If you give that input a name, then the browser should also add x,y co-
    >> ordinates for the pixel that the user clicked on to the resultant URL.

    >
    > The coordinates are not included unless there is a name="..." attribute.


    Isn't that what I said?

    --
    Toby A Inkster BSc (Hons) ARCS
    [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
    [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 5 days, 23:40.]

    Sharing Music with Apple iTunes
    http://tobyinkster.co.uk/blog/2007/11/28/itunes-sharing/
     
    Toby A Inkster, Nov 30, 2007
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TGFrc2htaSBOYXJheWFuYW4uUg==?=

    Google search result like site search!! How?

    =?Utf-8?B?TGFrc2htaSBOYXJheWFuYW4uUg==?=, May 5, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    715
    Lucas Tam
    May 6, 2005
  2. Andy
    Replies:
    1
    Views:
    374
    Jack Klein
    Nov 25, 2003
  3. Anand Pillai

    String search vs regexp search

    Anand Pillai, Oct 12, 2003, in forum: Python
    Replies:
    10
    Views:
    618
    Anand Pillai
    Oct 15, 2003
  4. mason66
    Replies:
    0
    Views:
    437
    mason66
    Jul 27, 2006
  5. Abby Lee
    Replies:
    5
    Views:
    474
    Abby Lee
    Aug 2, 2004
Loading...

Share This Page