473,786 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.selected Index];

select.selected Index = 0;
form.target = option.getAttri bute('name');
form.action = option.value;
form.submit();
//form.target = '';
//form.action = '';
}
</script>

<form method="get" name="search">
<select name="select" onChange="launc hIt()" style="font-size:9px">
<option value="">Select Service</option>
<option value="http://www.google.com/" name="google">G oogle</option>
<option value="http://www.hotbot.com/" name="hotbot">H otbot</option>
</select>
</form>
Jul 20 '05 #1
8 6296
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.selected Index];
window.open(opt ion.value,optio n.getAttribute( 'name'));
}
</script>

<form method="get" name="search">
<select name="select" onChange="launc hIt(this)" style="font-size:9px">
<option value="">Select Service</option>
<option value="http://www.google.com/" name="google">G oogle</option>
<option value="http://www.hotbot.com/" name="hotbot">H otbot</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.co m...
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.selected Index];
window.open(opt ion.value,optio n.getAttribute( 'name'));
}
</script>

<form method="get" name="search">
<select name="select" onChange="launc hIt(this)" style="font-size:9px">
<option value="">Select Service</option>
<option value="http://www.google.com/" name="google">G oogle</option>
<option value="http://www.hotbot.com/" name="hotbot">H otbot</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.selected Index];
if (option != ''){
window.open(opt ion.value,optio n.getAttribute( 'name'));
}
}
</script>
--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript 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.selected Index];
if (option != ''){
window.open(opt ion.value,optio n.getAttribute( 'name'));
}
}
</script>
--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript 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.selected Index];
if (option != ''){
window.open(opt ion.value,optio n.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.javas cript FAQ - http://jibbering.com/faq/
Jul 20 '05 #6
"Randy Webb" <hi************ @aol.com> wrote in message
news:8s******** ************@co mcast.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.selected Index];
if (option != ''){
window.open(opt ion.value,optio n.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.javas cript 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">S elect Service</option> <!-- this has an
empty value "" -->
<option value="http://www.anydomain.c om/" name="anydomain ">Anywhere</option>
<option value="http://www.whocares.co m/" name="whocares" >Who Cares</option>

TIA - Rob
Jul 20 '05 #7
"Rob Wahmann" <ro*@dotcomstud io.biz> wrote in message
news:H_******** *********@newss vr26.news.prodi gy.com...
"Randy Webb" <hi************ @aol.com> wrote in message
news:8s******** ************@co mcast.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.selected Index];
> if (option != ''){
> window.open(opt ion.value,optio n.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.javas cript 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">S elect Service</option> <!-- this has an
empty value "" -->
<option value="http://www.anydomain.c om/" name="anydomain ">Anywhere</option> <option value="http://www.whocares.co m/" name="whocares" >Who Cares</option>
TIA - Rob


function launchIt(select ) {
var option = select.options[select.selected Index];
if (option.getAttr ibute('name') != ''){
window.open(opt ion.value,optio n.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.javas cript 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
8849
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 (same folder). The cookie is not received. Can someone explain why? I worked around this by adding a cache-control header with a value of no-cache. This fixes the problem. Unfortunately that causes another problem with Internet Explorer...
6
8225
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 could help me here...? I'd like to use the window.open() script to open a separate window, because I'd like to hide the menubar and specify the window size as well. So I specify "javascript:window.open(...)" as the HTML link for a hotspot. However,...
3
37878
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 needs to be invoked on check/ uncheck). W3C Recomendation: 18 Scripts onselect = script The onselect event occurs when a user selects some text in a text field. This attribute may be used with the INPUT
6
16834
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 result from me being less than perfect in my preliminary coding on test pages. I had an <OPTION> element, 10 lines in size. Previously I used: onclick="fillFields()" and when I clicked on a line in the <OPTION> element, the data was
10
11241
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="#" onClick="window.open('/cgi-bin/displayimage.cgi?/store/demo/image.jpg&YOUR+PRODUCT%27<b>S+NAME+GOES', 'fullimage', 'WIDTH=420,HEIGHT=405,status=0')"> The original window should not reload, but is, and I have tested it with both version 4.72 and 7.02, and they both do it. IE does not do it....
10
6760
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 new window with maximized dimensions!) FYI, I uploaded the same code to: http://tosasoft.com/test/open.htm ========================================
3
24716
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 situation is: A main window opens child windows one at a time as the user requests, each with its own name. The user may click in any child window or the main window to open a summary window, which has a name all windows know. I want to get that...
7
3675
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 pageA.html 2. User clicks on menu link to open popup.html 3. pageA.html checks if popup.html is already open. It is not, open
13
3338
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 browser windows when clicked. I have found scripts that will allow one to open, and a few that claim to all multiples to be opened, but so far nothing that will allow a user to open multiple new windows as they click to see new samples. Does anyone...
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9492
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10108
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9960
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7510
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.