HTML Help Forum HTML Help
Please Search for the answer to your question before asking it! Thanks.
 

When I add 2 search-boxes on my page they don't work
Post a Reply to this Topic Ask a New Question Goto page 1, 2  Next
Click here to go to the original topic
       HTML Help Forum -> Javascript
View previous topic :: View next topic  
Author Message
Clay



Joined: 25 Dec 2008
Posts: 9

Posted: Thu Dec 25, 2008 8:03 am     When I add 2 search-boxes on my page they don't work  

But when i remove one the other works. This is the coding i used with a dropdown select box and search box next to it. Any code i need to add to make them work when side by side, each linking to different sites.


<script>
function chooseSearch(){
s = document.searchForm.engine.options[document.searchForm.engine.selectedIndex].value + document.searchForm.keywords.value
location = s
}
</script>
<form action=" " method="post" name="searchForm" id="searchForm" >
PayneLess Designs



Joined: 28 Feb 2007
Posts: 4288
Location: MS

Posted: Thu Dec 25, 2008 11:11 am      

You must change the action, id and name for the second one all through the script and form tag. Just add a two (2) to each. Code: <script type="text/javascript>
function chooseSearch(){
s = document.searchForm2.engine.options[document.searchForm2.engine.selectedIndex].value + document.searchForm2.keywords.value
location = s
}
</script>
<form action="none" method="post" name="searchForm2" id="searchForm2"> Hope that's right. :) Each one has to have it's own unique identifier.
Clay



Joined: 25 Dec 2008
Posts: 9

Posted: Thu Dec 25, 2008 12:48 pm      

Ah!! Thanks for that. Any change telling me how to open the search in a new window???



Thanks
PayneLess Designs



Joined: 28 Feb 2007
Posts: 4288
Location: MS

Posted: Thu Dec 25, 2008 8:43 pm      

Do you have link or code for complete search form(s)?
Clay



Joined: 25 Dec 2008
Posts: 9

Posted: Fri Dec 26, 2008 3:27 am      

Here the code. is not on site yet, just desktop.

<script>
function chooseSearch(){
s = document.searchForm.engine.options[document.searchForm.engine.selectedIndex].value + document.searchForm.keywords.value
location = s
}
</script>
<form action="" method="post" name="searchForm" id="searchForm" >
<select name="engine" style="FONT-WEIGHT: bold; FONT-SIZE: 11px; FONT-FAMILY: arial,tahoma,verdana,arial">
<option value="http://www.google.com/palm?q=" selected="selected">Google</option>
<option value="http://www.accuweather.com/pda/pda_5dy.asp?thisZip=">Zip Weather</option>
<option value="http://www.bigcharts.com/palm/bigcharts.asp?mode=Quote&amp;symb=">Ticker Quotes</option>
<option value="http://www.hollywood.com/avantgo/movies.asp?SearchDate&amp;searchradius=20&amp;SearchZip=">Zip Movies</option>
</select>
<input style="FONT-WEIGHT: bold; FONT-SIZE: 11px; FONT-FAMILY: geneva,arial,tahoma,verdana,arial" size="7" name="keywords" />
<input class="button" style="FONT-WEIGHT: bold; FONT-SIZE: 10px; FONT-FAMILY: geneva,arial,tahoma,verdana,arial" type="button" value="Find" name="Button" onclick="chooseSearch()"/>
</TR></TD></form>
PayneLess Designs



Joined: 28 Feb 2007
Posts: 4288
Location: MS

Posted: Fri Dec 26, 2008 2:11 pm      

This seems to be a bad link:

http://www.hollywood.com/avantgo/movies.asp?SearchDate&amp;searchradius=20&amp;SearchZip=

This one takes you to the page where you have to do searches using their search box:

http://www.accuweather.com/pda/pda_5dy.asp?thisZip=

Google and Ticker Quotes seem to work ok. Your code seems to work up to a point. Did make some changes in styling.
Clay



Joined: 25 Dec 2008
Posts: 9

Posted: Sat Dec 27, 2008 2:22 am      

But, yes. how do i get the link to open in a new window?

target=_"new" does not work.
PayneLess Designs



Joined: 28 Feb 2007
Posts: 4288
Location: MS

Posted: Sat Dec 27, 2008 2:40 am      

Need to get all the links working correctly before I look into the "new window" code. Have you checked the ones I said didn't seem to be working?
Clay



Joined: 25 Dec 2008
Posts: 9

Posted: Sat Dec 27, 2008 4:55 am      

all works now for new window link.



<script>
function chooseSearch(){
s = document.searchForm.engine.options[document.searchForm.engine.selectedIndex].value + document.searchForm.keywords.value
location = s
}
</script>
<form action="" method="post" name="searchForm" id="searchForm" >
<select name="engine" style="FONT-WEIGHT: bold; FONT-SIZE: 11px; FONT-FAMILY: arial,tahoma,verdana,arial">
<option value="http://www.google.com/palm?q=" selected="selected">Google</option>
<option value="http://www.bigcharts.com/palm/bigcharts.asp?mode=Quote&amp;symb=">Ticker Quotes</option>
</select>
<input style="FONT-WEIGHT: bold; FONT-SIZE: 11px; FONT-FAMILY: geneva,arial,tahoma,verdana,arial" size="7" name="keywords" />
<input class="button" style="FONT-WEIGHT: bold; FONT-SIZE: 10px; FONT-FAMILY: geneva,arial,tahoma,verdana,arial" type="button" value="Find" name="Button" onclick="chooseSearch()"/>
</TR></TD></form>
PayneLess Designs



Joined: 28 Feb 2007
Posts: 4288
Location: MS

Posted: Sat Dec 27, 2008 3:13 pm      

OK. Thanks for posting your solution back. Will consider this topic closed unless you have more. I see you did remove the links that weren't working properly.

The code you posted still doesn't open in a new window so maybe you changed your browser's Options/Preferences for tabs.

Should try coding that to HTML 4.01 Standards and use CSS for styling the form's tags.

Hope you and yours are having a great holiday.
Clay



Joined: 25 Dec 2008
Posts: 9

Posted: Sun Dec 28, 2008 4:19 am      

No, you dont get it. These search boxes normally dont open in a new window (like yahoo, google) unless u add a code to the link. I tried the target tag but it doesnt work so posted for any tag that may work with the script.
PayneLess Designs



Joined: 28 Feb 2007
Posts: 4288
Location: MS

Posted: Sun Dec 28, 2008 10:54 am      

Guess I don't get it as you said "all works now for new window link". Then you still have "new window" problem?
Clay



Joined: 25 Dec 2008
Posts: 9

Posted: Sun Dec 28, 2008 11:47 am      

PayneLess Designs wrote: Guess I don't get it as you said "all works now for new window link". Then you still have "new window" problem?

Yes, need code to open search in a new window. I ment all works for the links.
PayneLess Designs



Joined: 28 Feb 2007
Posts: 4288
Location: MS

Posted: Sun Dec 28, 2008 6:12 pm      

Haven't much time to work on that part, but maybe you can get this to open the search window like you want: Code: <script type="text/javascript">
function chooseSearch()
{
s = document.searchForm.engine.options[document.searchForm.engine.selectedIndex].value + document.searchForm.keywords.value + window.open()
location = s
}
</script> As it stands, it only opens a new blank tab including opening the regular search page in same window. Needs lots of work, but normal new window is: Code: onclick="window.open (this.href, ''); return false" Maybe you can work of some method using this.
Clay



Joined: 25 Dec 2008
Posts: 9

Posted: Tue Dec 30, 2008 7:27 am      

onclick="window.open (this.href, ''); return false"

top one does not work at all.



+ window.open()

This opens new window, but it is a blank while script goes on to load site in current page.
 
 
DARFUR
HOSTING / DESIGN
MAKE MONEY

       HTML Help Forum -> Javascript Goto page 1, 2  Next
Page 1 of 2


Powered by phpBB Search Engine Indexer
Powered by phpBB 2.0.19 © 2001, 2002 phpBB Group