473,383 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

onselect open new window

I'm having trouble with the following code appending the form name and an
empty value to the end of the url. Can anyone tell me what's wrong? I
appreciate any tips or advice you can pass along!

Rob

// submits info like this: http://www.google.com/?select=

<script type="text/javascript">
function launchIt() {
var form = document.search;
var select = form.select;
var option = select.options[select.selectedIndex];

select.selectedIndex = 0;
form.target = option.getAttribute('name');
form.action = option.value;
form.submit();
//form.target = '';
//form.action = '';
}
</script>

<form method="get" name="search">
<select name="select" onChange="launchIt()" style="font-size:9px">
<option value="">Select Service</option>
<option value="http://www.google.com/" name="google">Google</option>
<option value="http://www.hotbot.com/" name="hotbot">Hotbot</option>
</select>
</form>
Jul 20 '05 #1
8 6270
Lee
Rob Wahmann said:

I'm having trouble with the following code appending the form name and an
empty value to the end of the url. Can anyone tell me what's wrong? I
appreciate any tips or advice you can pass along!

Rob

// submits info like this: http://www.google.com/?select=


That's what happens when you submit a form using "get".
Your form elements and their values are appended to the URL.

In this case, your only form element is named "select", and
its value is "".

It looks like you don't really want to submit anything, just
open a window, so you should be using something more like:

<script type="text/javascript">
function launchIt(select) {
var option = select.options[select.selectedIndex];
window.open(option.value,option.getAttribute('name '));
}
</script>

<form method="get" name="search">
<select name="select" onChange="launchIt(this)" style="font-size:9px">
<option value="">Select Service</option>
<option value="http://www.google.com/" name="google">Google</option>
<option value="http://www.hotbot.com/" name="hotbot">Hotbot</option>
</select>
</form>

Jul 20 '05 #2
That works great! I should have been clearer in my last message... I knew
why it was happening but I didn't know how to resolve it. Thanks for the
assistance.

I have only one more question... How can I make the form do nothing if the
option value is empty ""? Thanks again for your help!

Rob

"Lee" <RE**************@cox.net> wrote in message
news:c2********@drn.newsguy.com...
Rob Wahmann said:

I'm having trouble with the following code appending the form name and an
empty value to the end of the url. Can anyone tell me what's wrong? I
appreciate any tips or advice you can pass along!

Rob

// submits info like this: http://www.google.com/?select=


That's what happens when you submit a form using "get".
Your form elements and their values are appended to the URL.

In this case, your only form element is named "select", and
its value is "".

It looks like you don't really want to submit anything, just
open a window, so you should be using something more like:

<script type="text/javascript">
function launchIt(select) {
var option = select.options[select.selectedIndex];
window.open(option.value,option.getAttribute('name '));
}
</script>

<form method="get" name="search">
<select name="select" onChange="launchIt(this)" style="font-size:9px">
<option value="">Select Service</option>
<option value="http://www.google.com/" name="google">Google</option>
<option value="http://www.hotbot.com/" name="hotbot">Hotbot</option>
</select>
</form>

Jul 20 '05 #3
Rob Wahmann wrote:
That works great! I should have been clearer in my last message... I knew
why it was happening but I didn't know how to resolve it. Thanks for the
assistance.

I have only one more question... How can I make the form do nothing if the
option value is empty ""? Thanks again for your help!

<script type="text/javascript">
function launchIt(select) {
var option = select.options[select.selectedIndex];
if (option != ''){
window.open(option.value,option.getAttribute('name '));
}
}
</script>
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 20 '05 #4
Hmm... I see where you're going with this but it still allows me to submit
empty values. Thanks for the assistance!

Rob
<script type="text/javascript">
function launchIt(select) {
var option = select.options[select.selectedIndex];
if (option != ''){
window.open(option.value,option.getAttribute('name '));
}
}
</script>
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #5
Rob Wahmann wrote:

Top posting fixed - please read the FAQ with regards to top-posting,
quoting and snipping.
<script type="text/javascript">
function launchIt(select) {
var option = select.options[select.selectedIndex];
if (option != ''){
window.open(option.value,option.getAttribute('name '));
}
}
</script>

Hmm... I see where you're going with this but it still allows me to submit
empty values. Thanks for the assistance!


"submit empty values" ?? You are not submitting a form, you are simply
opening a new window with a URL parameter. The parameter happens to be a
variable scenario that mimics a form post. To verify that, put an
onsubmit="alert('I am submitting')" on the form and see if you see it.
Using the above script, you won't. And as written, its not even
appending the variables, its simply opening a new window with the URL
set to the select value, and the name of the window being the same as
the "name" attribute of the option that was chosen at the time.

Perhaps a little more explanation of what you are trying to do?
Submitting a search to google takes a little more than what you are doing.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 20 '05 #6
"Randy Webb" <hi************@aol.com> wrote in message
news:8s********************@comcast.com...
Rob Wahmann wrote:

Top posting fixed - please read the FAQ with regards to top-posting,
quoting and snipping.
<script type="text/javascript">
function launchIt(select) {
var option = select.options[select.selectedIndex];
if (option != ''){
window.open(option.value,option.getAttribute('name '));
}
}
</script>

Hmm... I see where you're going with this but it still allows me to submit empty values. Thanks for the assistance!


"submit empty values" ?? You are not submitting a form, you are simply
opening a new window with a URL parameter. The parameter happens to be a
variable scenario that mimics a form post. To verify that, put an
onsubmit="alert('I am submitting')" on the form and see if you see it.
Using the above script, you won't. And as written, its not even
appending the variables, its simply opening a new window with the URL
set to the select value, and the name of the window being the same as
the "name" attribute of the option that was chosen at the time.

Perhaps a little more explanation of what you are trying to do?
Submitting a search to google takes a little more than what you are doing.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/


Sorry for any mistakes in posting to this thread (no professional news
poster here but i do appreciate the help). The empty value I'm referring to
is shown below. I want the ability to categorize options and not allow
windows to be launched where the value is "". If you select "Select Service"
below you'll see that a new window is launched to your default browser home
page. Instead, I would like for the form to do nothing. I'm toying around
with this but I greatly appreciate anyone's advice.

<option value="" name="select">Select Service</option> <!-- this has an
empty value "" -->
<option value="http://www.anydomain.com/" name="anydomain">Anywhere</option>
<option value="http://www.whocares.com/" name="whocares">Who Cares</option>

TIA - Rob
Jul 20 '05 #7
"Rob Wahmann" <ro*@dotcomstudio.biz> wrote in message
news:H_*****************@newssvr26.news.prodigy.co m...
"Randy Webb" <hi************@aol.com> wrote in message
news:8s********************@comcast.com...
Rob Wahmann wrote:

Top posting fixed - please read the FAQ with regards to top-posting,
quoting and snipping.
><script type="text/javascript">
> function launchIt(select) {
> var option = select.options[select.selectedIndex];
> if (option != ''){
> window.open(option.value,option.getAttribute('name '));
> }
> }
></script>
Hmm... I see where you're going with this but it still allows me to submit empty values. Thanks for the assistance!

"submit empty values" ?? You are not submitting a form, you are simply
opening a new window with a URL parameter. The parameter happens to be a
variable scenario that mimics a form post. To verify that, put an
onsubmit="alert('I am submitting')" on the form and see if you see it.
Using the above script, you won't. And as written, its not even
appending the variables, its simply opening a new window with the URL
set to the select value, and the name of the window being the same as
the "name" attribute of the option that was chosen at the time.

Perhaps a little more explanation of what you are trying to do?
Submitting a search to google takes a little more than what you are doing.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/


Sorry for any mistakes in posting to this thread (no professional news
poster here but i do appreciate the help). The empty value I'm referring

to is shown below. I want the ability to categorize options and not allow
windows to be launched where the value is "". If you select "Select Service" below you'll see that a new window is launched to your default browser home page. Instead, I would like for the form to do nothing. I'm toying around
with this but I greatly appreciate anyone's advice.

<option value="" name="select">Select Service</option> <!-- this has an
empty value "" -->
<option value="http://www.anydomain.com/" name="anydomain">Anywhere</option> <option value="http://www.whocares.com/" name="whocares">Who Cares</option>
TIA - Rob


function launchIt(select) {
var option = select.options[select.selectedIndex];
if (option.getAttribute('name') != ''){
window.open(option.value,option.getAttribute('name '));
}
}

Call me crazy but I believe I may have fixed this myself... The value or the
name can empty and that's fine with me. The script above seems to work.
Thanks again!

Rob
Jul 20 '05 #8
Rob Wahmann wrote:

<--snip-->
Call me crazy but I believe I may have fixed this myself... The value or the
name can empty and that's fine with me. The script above seems to work.
Thanks again!


Glad you got it working.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Paul | last post by:
I link to a web site from an Excel spreadsheet. The page i link to is getCookie.asp which sets a cookie then returns back some html which opens a new window, to the same site but a different page...
6
by: Les | last post by:
Hi, I'd like to find out how to use the window.open() script in Fireworks MX. I have posted my question in the Fireworks forum but didn't get any replies. Since it's javascript, maybe someone...
3
by: F. Da Costa | last post by:
Hi, Does the following indeed imply that this event is NOT called when an <input type="checkbox" is toggled? This would thus imply the usage of the onClick handler instead (assuming an action...
6
by: Hal Vaughan | last post by:
I'm using KDE on Linux, with Konqueror as the testing browser for this project. I've recently upgraded, so I realize some of the bugs I'm dealing with may or may not be my program, and could also...
10
by: Marshall Dudley | last post by:
When I do the following line in Netscape, the popup loads as it should, but the parent window usually, but not always, reloads as well. <a href="#"...
10
by: David McCulloch | last post by:
The following code opens a new window, but the "resizeTo" doesn't resize it. Why not? (Don't ask why I simply did not open the window with the new size....my original problem was how to open a...
3
by: NeverLift | last post by:
But, if it's not open, I don't want to open it . . . using window.open will open it if it doesn't exist, even if the url in that open is null (the window is then empty -- but it's open). The...
7
by: anthony.turcotte | last post by:
Hi, I've looked for a solution to this problem on google, read posts in this newsgroup and I still haven't found anything that could help me. Here's the scenario. 1. User accesses...
13
by: Geoff Fox | last post by:
I am in the final moments of designing a new website. One of the pages (http://www.auditionfactory.com/samples.php) has four links to show sample work. I would like these links to open new...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.