473,947 Members | 26,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Client-Side Object Reference Quandry

Please consider the following two if() structures. The first one fails, yet
the second works. Why? FWIW, I got the syntax of the first out of a working
page. I figured moving it to another page would be harmless. What's going on
here? The only major difference between the two pages that I can see so far
is that in the new page (where the first if() structure fails), the control
imgname is in a <form runat="server" method="post"> whereas in the page it
came from, there is no <Form> at all on the page. Could that have some
relevance?

// This one fails
if(v_incoming != "")
{
imgname.value = v_incoming; // this errors out with message: 'imgname' is
undefined.
}

// This one works
if(v_incoming != "")
{
var obj_imgname = document.all("i mgname");
obj_imgname.val ue = v_incoming; //no problems
}

here is the definition of imgname:
<input type="text" id="imgname" size="40" value="http://" NAME="imgname">

Thanks!
Nov 18 '05 #1
3 1119
yes, having a form defined matters.

<html>
<body>
<input type=text name=imgname id=imgname1>
<form name=myForm>
<input type=text name=imgname id=imgname1>
</form>
</body>
</html>

document.imgnam e.value //refers to the first one
document.myForm .imgname.value //refers to the second (as it is a child
of myForm)

document.all("i mgname") // is obsolete and
should never be used - would return an array

document.getEle mentsByTag('img name')[0] // referes to the first one
document.getEle mentsByTag('img name')[1] // referes to the second one

as id are required to be unique in a document unlike names, the following
should work

document.getEle mentById('imgna me1') // referes to the first one
document.getEle mentById('imgna me2') // referes to the second one

-- bruce (sqlwork.com)
"Fred" <th************ *@skruspammers. com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
Please consider the following two if() structures. The first one fails, yet the second works. Why? FWIW, I got the syntax of the first out of a working page. I figured moving it to another page would be harmless. What's going on here? The only major difference between the two pages that I can see so far is that in the new page (where the first if() structure fails), the control imgname is in a <form runat="server" method="post"> whereas in the page it
came from, there is no <Form> at all on the page. Could that have some
relevance?

// This one fails
if(v_incoming != "")
{
imgname.value = v_incoming; // this errors out with message: 'imgname' is undefined.
}

// This one works
if(v_incoming != "")
{
var obj_imgname = document.all("i mgname");
obj_imgname.val ue = v_incoming; //no problems
}

here is the definition of imgname:
<input type="text" id="imgname" size="40" value="http://" NAME="imgname">

Thanks!

Nov 18 '05 #2
In your first example - imagename is undefined. An easier way to do this is to use your form name.

example:

<form name="Form1">
<input type="text" id="imgname" size="40" value="http://" NAME="imgname">
</form>

if(v_incoming != "")
{
Form1.imgname.v alue = v_incoming;
}

Bobby Ryzhy
bobby@ domain below
http://weekendtech.net

On Mon, 12 Jul 2004 14:36:37 -0700, "Fred" <th************ *@skruspammers. com> wrote:
Please consider the following two if() structures. The first one fails, yet
the second works. Why? FWIW, I got the syntax of the first out of a working
page. I figured moving it to another page would be harmless. What's going on
here? The only major difference between the two pages that I can see so far
is that in the new page (where the first if() structure fails), the control
imgname is in a <form runat="server" method="post"> whereas in the page it
came from, there is no <Form> at all on the page. Could that have some
relevance?

// This one fails
if(v_incomin g != "")
{
imgname.value = v_incoming; // this errors out with message: 'imgname' is
undefined.
}

// This one works
if(v_incomin g != "")
{
var obj_imgname = document.all("i mgname");
obj_imgname.val ue = v_incoming; //no problems
}

here is the definition of imgname:
<input type="text" id="imgname" size="40" value="http://" NAME="imgname">

Thanks!


Bobby Ryzhy
bobby @ domain below
http://weekendtech.net
Nov 18 '05 #3
Wow, thanks. I guess I'll have to take JavaScript a bit more seriously!
"bruce barker" <no***********@ safeco.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
yes, having a form defined matters.

<html>
<body>
<input type=text name=imgname id=imgname1>
<form name=myForm>
<input type=text name=imgname id=imgname1>
</form>
</body>
</html>

document.imgnam e.value //refers to the first one
document.myForm .imgname.value //refers to the second (as it is a child of myForm)

document.all("i mgname") // is obsolete and
should never be used - would return an array

document.getEle mentsByTag('img name')[0] // referes to the first one
document.getEle mentsByTag('img name')[1] // referes to the second one

as id are required to be unique in a document unlike names, the following
should work

document.getEle mentById('imgna me1') // referes to the first one
document.getEle mentById('imgna me2') // referes to the second one

-- bruce (sqlwork.com)
"Fred" <th************ *@skruspammers. com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
Please consider the following two if() structures. The first one fails, yet
the second works. Why? FWIW, I got the syntax of the first out of a

working
page. I figured moving it to another page would be harmless. What's going on
here? The only major difference between the two pages that I can see so

far
is that in the new page (where the first if() structure fails), the

control
imgname is in a <form runat="server" method="post"> whereas in the page

it came from, there is no <Form> at all on the page. Could that have some
relevance?

// This one fails
if(v_incoming != "")
{
imgname.value = v_incoming; // this errors out with message: 'imgname'

is
undefined.
}

// This one works
if(v_incoming != "")
{
var obj_imgname = document.all("i mgname");
obj_imgname.val ue = v_incoming; //no problems
}

here is the definition of imgname:
<input type="text" id="imgname" size="40" value="http://" NAME="imgname">
Thanks!


Nov 18 '05 #4

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

Similar topics

2
2536
by: news.microsoft.com | last post by:
Hi I write dll library which one of it component will be Net socket communication. Communication is working very good, but i've got problem when client is connecting. When server is started, client is connecting without problems; but when servre is down and i start client, client connect to server! Few lines from code: client.Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
15
4512
by: Michael Rybak | last post by:
hi, everyone. I'm writing a 2-players game that should support network mode. I'm now testing it on 1 PC since I don't have 2. I directly use sockets, and both client and server do computations, the only data transfered is user mouse/kbd input. It works synchronously, but somehow, when I play in client window, both client and server have 17 fps, while when playing in server window, server has 44 fps while client ...
2
3044
by: Raquel | last post by:
How do I know whether the 'runtime client' and the 'application development client' are installed on my machine? When I issue the command "db2licm -l", it gives the following output: Product Name = "DB2 Personal Edition" Product Password = "DB2PE" Version Information = "8.1" Expiry Date = "Permanent" Annotation = "" Other information = ""
0
4262
by: Tim Northrup | last post by:
Help! We have DB2 V7.2 (fixpak 12) installed on Windows2003 Server, and the latest V7.2 client installed on another system. The DB2CODEPAGE on all systems is set to 1208, and the database was created with code set UTF-8 / codepage 1208. (Note: Running our test application described below on the database host as opposed to a separate client system produced the same results as described below). When we perform an INSERT statement...
2
4686
by: Rhino | last post by:
I am trying to verify that I correctly understand something I saw in the DB2 Information Center. I am running DB2 Personal Edition V8.2.1 on Windows. I came across the following in the Info Center: To return a result set from a procedure to the originating application, use the WITH RETURN TO CLIENT clause. When WITH RETURN TO CLIENT is specified on a result set, no nested procedures can access the result set.
2
1999
by: Delmar | last post by:
I need to build Web Application that will generate a client to execute some operations. Each client has running silent application. Maybe somebody can advice me what can I do ? Thank you.
2
7592
by: J Huntley Palmer | last post by:
I am having a horrific time integrating uw-imap's c-client for imap support in php. The problem is a whole bunch of "Text relocation remains referenced against symbol" errors during linking. Any help appreciated! The ordeal is a follows I am using Solaris 10 with php5.1.1. GCC:
2
7534
by: Frank Swarbrick | last post by:
I am trying to understand "client authentication" works. My environment is DB2/UDB LUW 8.2 on zSeries SLES9 as the database server and DB2 for VSE 7.4 as the client. We currently have DB2/LUW set up as follows: Client Userid-Password Plugin (CLNT_PW_PLUGIN) = Client Kerberos Plugin (CLNT_KRB_PLUGIN) = Group Plugin (GROUP_PLUGIN) = GSS Plugin for Local Authorization ...
0
1760
by: khu84 | last post by:
Here is client server very simple code, seems to work with telnet but with with web client code gives blank output. Following is the server code:- <?php function createSocketServer($host='192.168.1.34',$port=2222) { $max_clients = 10;
4
9313
MMcCarthy
by: MMcCarthy | last post by:
http://bytes.com/images/howtos/projectscope_blocks.jpgAs a freelance IT consultant for over 10 years, I’ve come to appreciate well defined project scopes. A project scope is a common understanding between you and your client as to what work is included in, or excluded from, a project.In a study done by CA towards end of last year, one third of all projects end up over budget and over-spend typically 10-20% of the original budget. Primary reasons...
0
9985
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
11577
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
11352
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
10694
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
8256
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
6118
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
4948
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
4540
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3544
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.