By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,608 Members | 1,925 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,608 IT Pros & Developers. It's quick & easy.

search box results in a new window

P: n/a
Hi,

I wish to use a dictionary.com search box and want the results of a search
to open in a new window. Is there a way to do this using their code? The
copy and paste code is provided below. Thanks for any help?

<form method="get" action="http://dictionary.reference.com/search">
<table border="0" cellspacing="4" cellpadding="4" bgcolor="#0033ff">
<tr>
<td valign="middle" align="left">
&nbsp;<strong style="font-family: arial,helvetica,sans-serif; font-size:
115%; color: #ffffff;">Search:</strong>&nbsp;
<select name="db" style="font-size:11pt; font-family:
arial,helvetica,sans-serif;">
<option value="*">Dictionary.com</option>
<option value="roget">Thesaurus.com</option>
<option value="wiki">Reference.com</option>
<option value="web">the Web</option>
</select>
&nbsp;<strong style="font-family: arial,helvetica,sans-serif; font-size:
115%; color: #ffffff;">for</strong>
&nbsp;<input type="text" name="q" size="20" maxlength="50"
style="font-size:11pt;">
&nbsp;<input type="submit" value="Go" style="font-weight:bold;
font-size:11pt; font-family: arial,helvetica,sans-serif;">
</td>
</tr>
</table>
</form>
Dec 23 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Is this with their permission? Or just a project for your personal
interest? Be careful of hitting someone elses' server without direct
consent. If you use their bandwidth (granted you'll be using an
insignificant amount) they may and will get pissed.

I wrote a script (server side) that parsed a site's racecar standings
into xml. I asked, never got a response so I went ahead anyway. Every
week or two during race season, the web developer rewrote the html file
so I had to rewrite the parser. Bastards!

Dec 23 '05 #2

P: n/a
"Someone" <no****@nospam.com> wrote in message
news:1c*****************************@40tude.net...
Hi,

I wish to use a dictionary.com search box and want the results of a search
to open in a new window. Is there a way to do this using their code? The
copy and paste code is provided below. Thanks for any help?


[snip]

Will this help? Watch for word-wrap.

<html>
<head>
<title>Dictionary.htm</title>
<script type="text/javascript">
var ref = new Array();
ref[0] = "http://dictionary.reference.com/search?q="
ref[1] = "http://thesaurus.reference.com/search?q=";
ref[2] = "http://www.reference.com/search?db=wiki&q=";
ref[3] = "http://www.reference.com/search?db=web&q=";
function formcheck() {
for (var i=0; i<4; i++) {
if (document.search_form.db[i].checked) {
var url = ref[i] + escape(document.search_form.q.value);
window.open(url,"Dictionary","");
}
}
}
</script>
</head>
<body onload="document.search_form.q.focus()">
<form name="search_form" method="get"
action="http://dictionary.reference.com/search" onsubmit="return
formcheck();">
<input type="text" name="q" value="" size="35" maxlength="256">
<input type="submit" value="Search"><br>
<input type="radio" name="db" value="*" id="d" checked>Dictionary
<input type="radio" name="db" value="roget" id="t">Thesaurus
<input type="radio" name="db" value="wiki" id="e">Encyclopedia
<input type="radio" name="db" value="web" id="w">Web
</form>
</body>
</html>
Dec 23 '05 #3

P: n/a
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:Kc********************@comcast.com...
"Someone" <no****@nospam.com> wrote in message
news:1c*****************************@40tude.net...
Hi,

I wish to use a dictionary.com search box and want the results of a search to open in a new window. Is there a way to do this using their code? The copy and paste code is provided below. Thanks for any help?


[snip]


Here it is with your interface but with CSS:

<html>
<head>
<title>Dictionary.html</title>
<script type="text/javascript">
var page = new Array();
page[0] = "http://dictionary.reference.com/search?q="
page[1] = "http://thesaurus.reference.com/search?q=";
page[2] = "http://www.reference.com/search?db=wiki&q=";
page[3] = "http://www.reference.com/search?db=web&q=";
function formcheck() {
var form = document.search_form;
var valu = form.q.value;
var pick = form.db.selectedIndex;
window.open(page[pick] + escape(valu),"Dictionary","");
}
</script>
<style type="text/css">
..style1 { font-family: arial,helvetica,sans-serif; font-size:115%;
font-weight: bold; color: #ffffff; padding: 10px; }
..style2 { font-size:11pt; font-family:arial,helvetica,sans-serif; }
..style3 {font-weight:bold; font-size:11pt; font-family:
arial,helvetica,sans-serif; }
</style>
</head>
<body onload="document.search_form.q.focus()">
<form method="get" name="search_form">
<table border="0" cellspacing="4" cellpadding="4" bgcolor="#0033ff">
<tr>
<td>
<span class="style1">Search:</span>
<select name="db" class="style2">
<option value="*">Dictionary.com</option>
<option value="roget">Thesaurus.com</option>
<option value="wiki">Reference.com</option>
<option value="web">the Web</option>
</select>
<span class="style1">for</span>
<input type="text" name="q" size="20" maxlength="50"
style="font-size:11pt;">
<input type="button" value="Go" class="style3" onclick="formcheck()">
</td>
</tr>
</table>
</form>
</body>
</html>
Dec 23 '05 #4

P: n/a
On Fri, 23 Dec 2005 16:38:20 -0600, McKirahan wrote:
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:Kc********************@comcast.com...
"Someone" <no****@nospam.com> wrote in message
news:1c*****************************@40tude.net...
Hi,

I wish to use a dictionary.com search box and want the results of a search to open in a new window. Is there a way to do this using their code? The copy and paste code is provided below. Thanks for any help?
[snip]


Here it is with your interface but with CSS:

<html>
<head>
<title>Dictionary.html</title>
<script type="text/javascript">
var page = new Array();
page[0] = "http://dictionary.reference.com/search?q="
page[1] = "http://thesaurus.reference.com/search?q=";
page[2] = "http://www.reference.com/search?db=wiki&q=";
page[3] = "http://www.reference.com/search?db=web&q=";
function formcheck() {
var form = document.search_form;
var valu = form.q.value;
var pick = form.db.selectedIndex;
window.open(page[pick] + escape(valu),"Dictionary","");
}
</script>
<style type="text/css">
.style1 { font-family: arial,helvetica,sans-serif; font-size:115%;
font-weight: bold; color: #ffffff; padding: 10px; }
.style2 { font-size:11pt; font-family:arial,helvetica,sans-serif; }
.style3 {font-weight:bold; font-size:11pt; font-family:
arial,helvetica,sans-serif; }
</style>
</head>
<body onload="document.search_form.q.focus()">
<form method="get" name="search_form">
<table border="0" cellspacing="4" cellpadding="4" bgcolor="#0033ff">
<tr>
<td>
<span class="style1">Search:</span>
<select name="db" class="style2">
<option value="*">Dictionary.com</option>
<option value="roget">Thesaurus.com</option>
<option value="wiki">Reference.com</option>
<option value="web">the Web</option>
</select>
<span class="style1">for</span>
<input type="text" name="q" size="20" maxlength="50"
style="font-size:11pt;">
<input type="button" value="Go" class="style3" onclick="formcheck()">
</td>
</tr>
</table>
</form>
</body>
</html>


Thanks for this, amazing! I have customised the code as below because
hitting enter did not work to get the results, but thanks again.

<input type="text" name="q" size="20" maxlength="50"
style="font-size:11pt;" onKeyDown="if(event.keyCode == 13) formcheck()">

Also can someone please explain what this is doing exactly, just so I am
aware.

<select name="db" class="style2"> <option value="*">Dictionary.com</option>


What's with the value of '*'?
Dec 24 '05 #5

P: n/a
On 23 Dec 2005 14:07:14 -0800, bobzimuta wrote:
Is this with their permission? Or just a project for your personal
interest? Be careful of hitting someone elses' server without direct
consent. If you use their bandwidth (granted you'll be using an
insignificant amount) they may and will get pissed.

I wrote a script (server side) that parsed a site's racecar standings
into xml. I asked, never got a response so I went ahead anyway. Every
week or two during race season, the web developer rewrote the html file
so I had to rewrite the parser. Bastards!


The website advertises a free search engine for use on other websites and
provides code to integrate into your web page. There is nothing saying the
code cannot be customised that I am aware of either. Linking to other sites
should never be a problem surely.
Dec 24 '05 #6

P: n/a
"Someone" <no****@nospam.com> wrote in message
news:1i*****************************@40tude.net...
On Fri, 23 Dec 2005 16:38:20 -0600, McKirahan wrote:
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:Kc********************@comcast.com...
"Someone" <no****@nospam.com> wrote in message
news:1c*****************************@40tude.net...
Hi,

I wish to use a dictionary.com search box and want the results of a search
to open in a new window. Is there a way to do this using their code?

The
copy and paste code is provided below. Thanks for any help?


[snip]
Thanks for this, amazing! I have customised the code as below because
hitting enter did not work to get the results, but thanks again.

<input type="text" name="q" size="20" maxlength="50"
style="font-size:11pt;" onKeyDown="if(event.keyCode == 13) formcheck()">

Also can someone please explain what this is doing exactly, just so I am
aware.

<select name="db" class="style2">
<option value="*">Dictionary.com</option>


What's with the value of '*'?


Rather than worry about key events; try this instead:

<html>
<head>
<title>Dictionary.html</title>
<script type="text/javascript">
var page = new Array();
page[0] = "http://dictionary.reference.com/search?q="
page[1] = "http://thesaurus.reference.com/search?q=";
page[2] = "http://www.reference.com/search?db=wiki&q=";
page[3] = "http://www.reference.com/search?db=web&q=";
function formcheck() {
var form = document.search_form;
var valu = form.q.value;
if (valu.length == 0) return false;
var pick = form.db.selectedIndex;
window.open(page[pick] + escape(valu),"Dictionary","");
return false;
}
</script>
<style type="text/css">
..style1 { font-family: arial,helvetica,sans-serif; font-size:115%;
font-weight: bold; color: #ffffff; padding: 10px; }
..style2 { font-size:11pt; font-family:arial,helvetica,sans-serif; }
..style3 {font-weight:bold; font-size:11pt; font-family:
arial,helvetica,sans-serif; }
</style>
</head>
<body onload="document.search_form.q.focus()">
<form method="get" name="search_form" onsubmit="return formcheck()">
<table border="0" cellspacing="4" cellpadding="4" bgcolor="#0033ff">
<tr>
<td>
<span class="style1">Search:</span>
<select name="db" class="style2">
<option value="*">Dictionary.com</option>
<option value="roget">Thesaurus.com</option>
<option value="wiki">Reference.com</option>
<option value="web">the Web</option>
</select>
<span class="style1">for</span>
<input type="text" name="q" size="20" maxlength="50"
style="font-size:11pt;">
<input type="submit" value="Go" class="style3">
</td>
</tr>
</table>
</form>
</body>
</html>
The "*" just assures that there is a value for the default selection.
Dec 24 '05 #7

P: n/a
McKirahan wrote:
[...]

Rather than worry about key events; try this instead:

<html>
<head>
<title>Dictionary.html</title>
<script type="text/javascript">
var page = new Array();
page[0] = "http://dictionary.reference.com/search?q="
page[1] = "http://thesaurus.reference.com/search?q=";
page[2] = "http://www.reference.com/search?db=wiki&q=";
page[3] = "http://www.reference.com/search?db=web&q=";
function formcheck() {
var form = document.search_form;
var valu = form.q.value;
if (valu.length == 0) return false;
var pick = form.db.selectedIndex;
window.open(page[pick] + escape(valu),"Dictionary","");
return false;
}
</script>
<style type="text/css">
.style1 { font-family: arial,helvetica,sans-serif; font-size:115%;
font-weight: bold; color: #ffffff; padding: 10px; }
.style2 { font-size:11pt; font-family:arial,helvetica,sans-serif; }
.style3 {font-weight:bold; font-size:11pt; font-family:
arial,helvetica,sans-serif; }
</style>
</head>
<body onload="document.search_form.q.focus()">
<form method="get" name="search_form" onsubmit="return formcheck()">
<table border="0" cellspacing="4" cellpadding="4" bgcolor="#0033ff">
<tr>
<td>
<span class="style1">Search:</span>
<select name="db" class="style2">
<option value="*">Dictionary.com</option>
<option value="roget">Thesaurus.com</option>
<option value="wiki">Reference.com</option>
<option value="web">the Web</option>


I don't understand why you use values for the options then ignore them
when accessing the array. It makes the order of the values in the
array dependent on the order of the options.

Why not use the option value as the key to an object? e.g.

var page = {
dictionary : "http://dictionary.reference.com/search?q=",
roget : "http://thesaurus.reference.com/search?q=",
wiki : "http://www.reference.com/search?db=wiki&q=",
web : "http://www.reference.com/search?db=web&q="
}
Then the function changes to:

var pick = form.db.options[form.db.selectedIndex].value;

And the order of items in the page object is independent of the order
of the options in the select.
[...]
--
Rob
Dec 24 '05 #8

P: n/a
"RobG" <rg***@iinet.net.auau> wrote in message
news:43***********************@per-qv1-newsreader-01.iinet.net.au...

[snip]
I don't understand why you use values for the options then ignore them
when accessing the array. It makes the order of the values in the
array dependent on the order of the options.

Why not use the option value as the key to an object? e.g.

var page = {
dictionary : "http://dictionary.reference.com/search?q=",
roget : "http://thesaurus.reference.com/search?q=",
wiki : "http://www.reference.com/search?db=wiki&q=",
web : "http://www.reference.com/search?db=web&q="
}
Then the function changes to:

var pick = form.db.options[form.db.selectedIndex].value;

And the order of items in the page object is independent of the order
of the options in the select.


Good point.

I originally posted one approach (and later merged it with the OP's)
whose form was strictly based on dictionary.com's.
Dec 24 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.