/    Sign up×
Community /Pin to ProfileBookmark

Dynamically change hyperlink based on the keywords.

Hi,

I am trying to come up with something like [url]www.turboscout.com[/url] but for my own convenience as we have to go through a lot of websites daily to search for info and this would save me a lot of time.
Basically , like turboscout.com, I want to search 5 of my sites by putting the info from the textbox into the hyperlinks.

What I will have is a page with certain links on it for different sites, for example on the top of the page will be a textbox and below it there will be a few sites like [url]http://www.petco.com/[/url] for example.
Now when I put the keywords “puppy food” in the textbox and click on Petco.com , it should go to [url]http://www.petco.com/Shop/SearchResults.aspx?Nav=1&N=0&Ntt=puppy%20food[/url].

Hope that makes sense

I am quite familiar with HTML but I suck at programming, so any starting tips would be appreciated…. I know this shouldn’t be a lot of work and there might be some script already out there, but I looked for a few hours before I am asking here.

Thanks a lot for any help… will be very appreciated!

Regds,

Nrupesh
nrupesh(at)usa.net

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@VladdyApr 08.2006 — <input type="text" id="mySearchBox" />

<a href="http://www.petco.com" onclick="this.href+='/Shop/SearchResults.aspx?Nav=1&N=0&Ntt='+document.getElementById('mySearchBox').value">PETCO</a>

Though you should be thinking about an accessible solution: make all those links a submit button and do the redirection on the server
Copy linkTweet thisAlerts:
@nrupeshauthorApr 08.2006 — Thanks mate... I'll try that out and reply on the outcome!

Thanks

Nrupesh

www.pavs.biz
Copy linkTweet thisAlerts:
@nrupeshauthorApr 08.2006 — <input type="text" id="mySearchBox" />

<a href="http://www.petco.com" onclick="this.href+='/Shop/SearchResults.aspx?Nav=1&N=0&Ntt='+document.getElementById('mySearchBox').value">PETCO</a>

Though you should be thinking about an accessible solution: make all those links a submit button and do the redirection on the server[/QUOTE]


Done... I could modify it to exactly what I wanted, thanks!

Only one more problem now, when I put in the keyword and click on the link, it will launch the site in a new window with exactly what I want BUT in my site it changes the link so if I put another keyword in then it appends it to the already generated link.

Any way to reset the link to the original one?

E.g. when I search PETCO it will open petco with the results on a new page, but on my page it changes the link to "www.petco.com/shop/search..." instead of reverting it back to just "www.petco.com".

Thanks for the help again ?

Nrupesh
Copy linkTweet thisAlerts:
@VladdyApr 08.2006 — Best is to let it open in the same window so that when you do back to your page things reset. Otherwise, you can handle the window opening using javascript method - then the original href is not modified:

<script type="text/javascript">

function doSearch(anchor,page)

{ window.open(anchor.href + page + document.getElementById('mySearchBox').value);

return false;

}

</script>

<a href="http://www.petco.com" onclick="return doSearch(this,'/Shop/SearchResults.aspx?Nav=1&N=0&Ntt=');">PETCO</a>
×

Success!

Help @nrupesh spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...