...

View Full Version : Need a little help



anarch
07-01-2011, 02:10 AM
Ok, this should be easy but for me it doesn't seem so... probably because i'm very close to the deadline and have a lot to do.

This is what i'm trying to do;
I have an html form with a textfield and a button - whenever the button is clicked or enter is pressed i would like it to goto a particular page and place the text field's value on the end as a hash.

for instance;
user enters "test" and presses enter or hits the button and the page goes to "google.com#test"'

edit: to clarify I would like it to add the hash on the end of the href for the page it should goto

jmrker
07-01-2011, 02:59 AM
<!DOCTYPE HTML>
<html>
<head>
<title> Untitled </title>
<script type="text/javascript">
function GoTo() {
document.location = "http://www.google.com#"+document.getElementById('hashContent').value;
}
</script>

</head>
<body>
Go to www.google#<input type="text" id="hashContent" value="">
<button onclick="GoTo()">Go</button>
</body>
</html>

Of course you realize that if the user miss-types the hash, it won't go where you want.

bullant
07-01-2011, 03:16 AM
it's probably a good idea to encodeURIComponent() the user input.

anarch
07-01-2011, 04:03 AM
it doesn't matter what they type because it's a search field. I have to use the url bar to transfer information across joomla mods from one page to another.
That method didn't work at all even with URI encoding.

without uri encoding all it does is add "searchTerm=" to the url bar - with uri encoding it does get the word up there but not beginning with a # nor does it go to the page

jmrker
07-01-2011, 04:32 AM
it doesn't matter what they type because it's a search field. I have to use the url bar to transfer information across joomla mods from one page to another.
That method didn't work at all even with URI encoding.

without uri encoding all it does is add "searchTerm=" to the url bar - with uri encoding it does get the word up there but not beginning with a # nor does it go to the page

So, bottom line is that neither suggestion helped?
:confused:

anarch
07-01-2011, 04:39 AM
Unfortunately not. -_-

I already tried yours before coming here lol. I'm not sure why this is so complicated really... lol.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum