M
Mike Weathery
Hi all
I am using the following function in a text entry box:
function goToTV() {
location.href="http://www.tvguide.com" + "/search/index.aspx?keyword=" +
document.search.q.value;
return false;
}
E.g. if the user types in "Lost" then clicks 'TV', it sends them to the URL:
http://www.tvguide.com/search/index.aspx?keyword=Lost
However sometimes I want people to just be able to click TV without typing a
search keyword, but this causes problems as the target site does not
understand
http://www.tvguide.com/search/index.aspx?keyword=
In that case I want it just to go to
http://www.tvguide.com
Q: Is there a way to make the js only apply the '+
"/search/index.aspx?keyword=" + document.search.q.value;' part if there is
text entered in q?
E.g. location.href="http://www.tvguide.com" + ONLY IF Q CONTAINS TEXT THEN
ADD "/search/index.aspx?keyword=" + document.search.q.value;
Thanks in advance for any simple mod to my above js that can do this.
M.
I am using the following function in a text entry box:
function goToTV() {
location.href="http://www.tvguide.com" + "/search/index.aspx?keyword=" +
document.search.q.value;
return false;
}
E.g. if the user types in "Lost" then clicks 'TV', it sends them to the URL:
http://www.tvguide.com/search/index.aspx?keyword=Lost
However sometimes I want people to just be able to click TV without typing a
search keyword, but this causes problems as the target site does not
understand
http://www.tvguide.com/search/index.aspx?keyword=
In that case I want it just to go to
http://www.tvguide.com
Q: Is there a way to make the js only apply the '+
"/search/index.aspx?keyword=" + document.search.q.value;' part if there is
text entered in q?
E.g. location.href="http://www.tvguide.com" + ONLY IF Q CONTAINS TEXT THEN
ADD "/search/index.aspx?keyword=" + document.search.q.value;
Thanks in advance for any simple mod to my above js that can do this.
M.