473,770 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Select Menu Option <create on the fly>

Picking up from Friday..
I am still having trouble creating the Select Menu option. I got parts
of the correct syntax but it is still not creating the selected carrier
as an option in the parent page.

Help apprecitate,. I currently have it commented out just to show the
line to you better:

function onCarrierSelect () {
var frm = document.carrRe questForm.carri erList.selected Index;
var selectCar =
document.carrRe questForm.carri erList.options[frm].text;
var varEl = "<%=varElementN ame%>";
if (window.opener && !window.opener. close)
var oOption = window.opener.d ocument.createE lement("OPTION" );
// window.opener.f orm.[varEl].options.add(oO ption);
oOption.innerTe xt =selectCar;
oOption.value =selectCar;
window.close();
}

Jul 17 '06 #1
3 2684
It is breaking/erroring at:
var oOption = window.opener.d ocument.createE lement("OPTION" );

This is a pop-up window select menu that when a value is chosen will
populate the parent window select menu.

Does oOption need to reference the form[0] and the varEl?
How does it know what form to create an option for?

I see the 4th line trys to do this:

window.opener.f orm[0].elements[varEl].options[window.opener.f orm[0].elements[varEl].options.length]
= oOption;

The error I am getting is:
Error: 'undefined' is null or not an object.

function onCarrierSelect () {
var frm = document.carrRe questForm.carri erList.selected Index;
var selectCar =
document.carrRe questForm.carri erList.options[frm].text;
var varEl = "<%=varElementN ame%>";
if (window.opener && !window.opener. close)
var oOption = window.opener.d ocument.createE lement("OPTION" );
// assigns object name to create Option tag
oOption.innerTe xt =selectCar;
oOption.value =selectCar;

window.opener.f orm[0].elements[varEl].options[window.opener.f orm[0].elements[varEl].options.length]
= oOption;
window.close();
}
jo********@gmai l.com wrote:
Picking up from Friday..
I am still having trouble creating the Select Menu option. I got parts
of the correct syntax but it is still not creating the selected carrier
as an option in the parent page.

Help apprecitate,. I currently have it commented out just to show the
line to you better:

function onCarrierSelect () {
var frm = document.carrRe questForm.carri erList.selected Index;
var selectCar =
document.carrRe questForm.carri erList.options[frm].text;
var varEl = "<%=varElementN ame%>";
if (window.opener && !window.opener. close)
var oOption = window.opener.d ocument.createE lement("OPTION" );
// window.opener.f orm.[varEl].options.add(oO ption);
oOption.innerTe xt =selectCar;
oOption.value =selectCar;
window.close();
}
Jul 17 '06 #2
jo********@gmai l.com wrote:
It is breaking/erroring at:
var oOption = window.opener.d ocument.createE lement("OPTION" );
If you're trying to do this from IE, you can't.
Creating a new option and adding it to a select list must be done from code
within the same page.
So, in your main document write a function which accepts the new Option()
parameters and creates it there.
Then in your popup, call that function in window.opener to do the work.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Jul 17 '06 #3
I have the code to do it. But it is two functions I hacked together.

Does anyone know if I can "clean" it up some?

THank you.

function onCarrierSelect () {
var frm = document.carrRe questForm.carri erList.selected Index;
var selectCar =
document.carrRe questForm.carri erList.options[frm].text;
var varEl = "<%=varElementN ame%>";
if (window.opener && !window.opener. close)
var oOption = window.opener.d ocument.createE lement('option' ); //
assigns object name to create Option tag
insertOptionBef ore(varEl, selectCar)
window.close();
}
function insertOptionBef ore(varElementN ame, selectCar)
{
var elSel = window.opener.d ocument.getElem entById(varElem entName);
if (elSel.selected Index >= 0) {
var elOptNew = window.opener.d ocument.createE lement('option' );
elOptNew.text = selectCar;
elOptNew.value = selectCar;
var elOptOld = elSel.options[0];
try {
elSel.add(elOpt New, elOptOld); // standards compliant; doesn't
work in IE
}
catch(ex) {
elSel.add(elOpt New, elSel.selectedI ndex); // IE only
elSel.selectedI ndex = elSel.selectedI ndex -1
}
}
}
Matt Kruse wrote:
jo********@gmai l.com wrote:
It is breaking/erroring at:
var oOption = window.opener.d ocument.createE lement("OPTION" );

If you're trying to do this from IE, you can't.
Creating a new option and adding it to a select list must be done from code
within the same page.
So, in your main document write a function which accepts the new Option()
parameters and creates it there.
Then in your popup, call that function in window.opener to do the work.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Jul 18 '06 #4

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

Similar topics

4
2227
by: Dan | last post by:
Hi, I would just like to know if the istream operator takes only one parammeter(object) at a time (like z) ? istream operator>>(istream& in, Shape &z) Cause I keep getting error concerning the amount my operator has for bother cin , cout operator<< and >> thanks Dan
6
3017
by: Omar | last post by:
Hi, In a JSP I have the next: .... codigo = "<select name='" + nombre + "'>\n<option selected value='default'>Escoge</option><option value='todos'>Todos</option>"; if (miRS != null) while (miRS.next()) {
2
10183
by: Jasonkimberson | last post by:
I am doing a data pull of HTML from a database that will be put into a drop down menu currently after i pull and populate the information, it converts my < into &lt; whats the work around for this? HTML code
6
13024
by: Chris Fink | last post by:
Does anyone know it is possible to include a small image(.gif .jpeg) within a <SELECT><option> so that the user would see the option text as well as a little image(icon) in the option? I know this is not an ASP.NET related question, but I know this group is knowledgeable and quick with responses. Thanks
1
1869
by: frey | last post by:
i tried to create a dropdown menu and use the option as a control to change content inside another text area the code is like this: <select name="xxxx"><option onclick="changeunitprice(29.87)" value="1744"/> the function changeunitprice() is called when an option is selected
4
2185
by: Kentor | last post by:
I have some info that im grabbing from a mysql database with php and i want to make an xml file but i know that i need to be carefull with the & sign and so on... how can i clean the data coming from the db to have a valid xml file?
5
6467
by: Screaming Eagles 101 | last post by:
Hi , not much trouble in making a setup project, but I'd like also an icon in All Programs to uninstall the application. I can't find a good explanation on the net so far... -- Filip http://www.ww2airborne.net/
5
2216
by: consonanza | last post by:
I am working on a report filter form. It has 2 combo boxes (cmboSelectSubject and cmboSelectCategory) to select criteria. Selecting an entry in combo 1 restricts the options available in combo 2. The row source for combo2 is: SELECT DISTINCT tblComplaintCategory.fldComplaintCategory, tblComplaintCategory.fldComplaintCategoryID, tblComplaintSubjects.fldComplaintSubjectID
5
5157
by: Hels Bells | last post by:
Hi, I'm looking to do some manipulation on a string containing html code in asp which will involve me either using some regular expressions or just plain old simple replace functionality. The text that I want to use will have double quotes in it (as it's xhtml code) so I can't set it as a string value and is actually brought into the page from a content managed element (the details of which I don't think I'll need to go into but...
0
9595
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
10232
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10059
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10008
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
9873
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...
1
7420
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
6682
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();...
1
3974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2822
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.