Search button

S

Shelly

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.
 
B

BootNic

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>
 
S

Shelly

BootNic said:
<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
 
T

Toby A Inkster

Shelly said:
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/
 
J

Jukka K. Korpela

Scripsit Toby A Inkster:
Shelly wrote: - -

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.
 
S

Shelly

Toby said:
Yep. That's certainly the easiest way.


<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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top