473,771 Members | 2,394 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing a reference to the popup window

Is there a way, I could pass the reference to a pop up window to
another function?

Basically, this is what I want to
var win= window.open("x. htm".....)

SetValue(win,"t xtName");

//-------------------------------------------
function SetValue (win, ctlID)
{
var obj=win.getElem entByID(ctlID);
ctlID.value="Hi ";
}
I am getting errors when I do this. Any help is appreciated. Thanks
_GJK

Nov 23 '05 #1
1 1912
DIZZIEDAZZ wrote:
Is there a way, I could pass the reference to a pop up window to
another function?
Of course there is.
Basically, this is what I want to
var win= window.open("x. htm".....)

SetValue(win,"t xtName");

//-------------------------------------------
function SetValue (win, ctlID)
Consider using a lowercase character for first character of the function
identifier. It helps to tell simple functions and those designed to serve
as constructors apart, and is thus considered a Good Thing regarding code
style.
{
var obj=win.getElem entByID(ctlID);
ctlID.value="Hi ";
`ctlID' is a string, not the object reference you tried to retrieve.
}
I am getting errors when I do this. [...]


"Does not work" is a useless error description. [psf 4.11]
See <http://jibbering.com/faq/#FAQ4_43>.

getElementById( ) -- notice the case -- is a method of Document objects,
not of Window objects. Try

var obj = win.document.ge tElementById(ct lID);
if (obj && typeof obj.value != "undefined" )
{
obj.value = "Hi";
}

See also

<http://www.quirksmode. org/js/support.html>
<http://pointedears.de/scripts/test/whatami>

for required feature tests (an example was given above).

However, since you are trying to assign something to the `value' property
in the process, I assume you are trying to modify the value of a form
control. You should not use getElementById( ) in that case as it requires
W3C DOM Level 2 Support and is probably slower than the alternative.

Consider making it a child element of a `form' element; this would allow
you to refer to the form control by

win.document.fo rms[...].elements[ctlID]

where `...' would either be the 0-based index or the name string of the
`form' element. Most of this referencing (after document) is specified
in W3C DOM Level 2 HTML, however it is also backwards compliant.
HTH

PointedEars
Nov 23 '05 #2

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

Similar topics

2
16902
by: N/A | last post by:
Hey all, If I open a popup like this window.open('http://www.google.com', 'popup', 'width = 618, height = 425, directories = no, location = no, menubar = no, resizable = no, scrollbars = yes, status = no, toolbar = no'); Then I know that there is a window object in the windows collection called 'popup'. So how can I make that window come to the front? Looking for
6
7094
by: veganeater | last post by:
Hi Everyone, I was wondering if there was a way to pass a variable to a popup window. The purpose is make it so when a user clicks on a specific region/link of the glossary page, a popup opens with the related description. This is done and is obviously not a concern. However, now I would like to make it so the corresponding row becomes highlighted (changes background colour via DOM). I imagine it can be done, but I'm at a loss for...
3
4067
by: Aaron | last post by:
I am having a little difficulty with a relatively simple task. I have a parent webform. I have a javascript attribute added to a button to open a new window when clicked. The user fills in a textbox then clicks the button and on page load the child window should grab that val run a query an present the results. Given that I am bouncing between server side controls and client script. I am just having a little trouble passing my textbox...
3
3456
by: michael | last post by:
let me keep it clean, quick and simple. I am passing a variable into another window and am reassigning the value on the new page - window.document...value = opener.document. ....value and am wanting to then use this value within an element of a form on the current page -
12
37874
meenakshia
by: meenakshia | last post by:
hi forum i have read a lot of articles regarding passing data from popup to parent up but i m looking for the opposite that is from parent to popup window pls help me in this regard i have three input fields in parent window and three in popup window parent.htm
0
9619
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
9454
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,...
0
10260
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...
1
10038
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
6712
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
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
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
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
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.