473,395 Members | 1,999 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,395 software developers and data experts.

Updating a texbox with Javascript

I am working with some pre-written code that dynamically builds a page with
user controls based on data. I need to attach my Javascript to one of the
controls on the form - I do not have access to the code of the master page.
Because of this my <javascript> ends up inside the <form> tag. I want to
simply update some textboxes from a grid using Javascript but it does not
work.

I know that you are not supposed to have the script within the form, but I
am not at liberty to change the setup - I'm just writing one of the controls.

Here is a very simlified view of what I see when I selece View/Source from IE:

<HTML>
<HEAD>
<title>My Title </title>
<link href="Includes/styles.css" rel="stylesheet">
</HEAD>
<body id="webMainPage">
<form name="_ctl0" method="post" action="…" language="javascript"
onsubmit="ValidatorOnSubmit();" id="_ctl0">

<script language="javascript">
function GridRowSelect() {
document.forms[0].elements['myText'].value = 'Deos not work';
document._ctl0.myText.value = ‘Doesn’t work either’; }
</script>

<TABLE id="Table1">
<tr><td> …
</form>
</body>
</HTML>

All of the javascript code for the grid control is generated within the
<form> tags and it seems to work fine. Would SmartNavigation have anything
to do with it? Is there any other way I can get at the field in this
scenario?

Thanks in advance,
Denise
Nov 19 '05 #1
3 1973
Did you try document.getElementById('myText')?

Eliyahu

"Denise" <De****@discussions.microsoft.com> wrote in message
news:90**********************************@microsof t.com...
I am working with some pre-written code that dynamically builds a page with user controls based on data. I need to attach my Javascript to one of the
controls on the form - I do not have access to the code of the master page. Because of this my <javascript> ends up inside the <form> tag. I want to
simply update some textboxes from a grid using Javascript but it does not
work.

I know that you are not supposed to have the script within the form, but I
am not at liberty to change the setup - I'm just writing one of the controls.
Here is a very simlified view of what I see when I selece View/Source from IE:
<HTML>
<HEAD>
<title>My Title </title>
<link href="Includes/styles.css" rel="stylesheet">
</HEAD>
<body id="webMainPage">
<form name="_ctl0" method="post" action="." language="javascript"
onsubmit="ValidatorOnSubmit();" id="_ctl0">

<script language="javascript">
function GridRowSelect() {
document.forms[0].elements['myText'].value = 'Deos not work';
document._ctl0.myText.value = 'Doesn't work either'; }
</script>

<TABLE id="Table1">
<tr><td> .
</form>
</body>
</HTML>

All of the javascript code for the grid control is generated within the
<form> tags and it seems to work fine. Would SmartNavigation have anything to do with it? Is there any other way I can get at the field in this
scenario?

Thanks in advance,
Denise

Nov 19 '05 #2
> Did you try document.getElementById('myText')?
Yes. When I try:
var x1 = document.getElementById('IDText');
x1.value = "does it work?"
I get the error:
Microsoft JScript runtime error: 'null' is null or not an object

Denise
"Eliyahu Goldin" wrote:
Did you try document.getElementById('myText')?

Eliyahu

"Denise" <De****@discussions.microsoft.com> wrote in message
news:90**********************************@microsof t.com...
I am working with some pre-written code that dynamically builds a page

with
user controls based on data. I need to attach my Javascript to one of the
controls on the form - I do not have access to the code of the master

page.
Because of this my <javascript> ends up inside the <form> tag. I want to
simply update some textboxes from a grid using Javascript but it does not
work.

I know that you are not supposed to have the script within the form, but I
am not at liberty to change the setup - I'm just writing one of the

controls.

Here is a very simlified view of what I see when I selece View/Source from

IE:

<HTML>
<HEAD>
<title>My Title </title>
<link href="Includes/styles.css" rel="stylesheet">
</HEAD>
<body id="webMainPage">
<form name="_ctl0" method="post" action="." language="javascript"
onsubmit="ValidatorOnSubmit();" id="_ctl0">

<script language="javascript">
function GridRowSelect() {
document.forms[0].elements['myText'].value = 'Deos not work';
document._ctl0.myText.value = 'Doesn't work either'; }
</script>

<TABLE id="Table1">
<tr><td> .
</form>
</body>
</HTML>

All of the javascript code for the grid control is generated within the
<form> tags and it seems to work fine. Would SmartNavigation have

anything
to do with it? Is there any other way I can get at the field in this
scenario?

Thanks in advance,
Denise


Nov 19 '05 #3
I found a solution. The reason the standard javascript reference did not
work is because the page is being dynamically created from several user
controls. A textbox that I named 'IDText' is being renamed _ctl1_IDText.
This syntax works:

this.document.forms[0].elements['_ctl1_IDText'].value = "working!";
"Denise" wrote:
Did you try document.getElementById('myText')?

Yes. When I try:
var x1 = document.getElementById('IDText');
x1.value = "does it work?"
I get the error:
Microsoft JScript runtime error: 'null' is null or not an object

Denise
"Eliyahu Goldin" wrote:
Did you try document.getElementById('myText')?

Eliyahu

"Denise" <De****@discussions.microsoft.com> wrote in message
news:90**********************************@microsof t.com...
I am working with some pre-written code that dynamically builds a page

with
user controls based on data. I need to attach my Javascript to one of the
controls on the form - I do not have access to the code of the master

page.
Because of this my <javascript> ends up inside the <form> tag. I want to
simply update some textboxes from a grid using Javascript but it does not
work.

I know that you are not supposed to have the script within the form, but I
am not at liberty to change the setup - I'm just writing one of the

controls.

Here is a very simlified view of what I see when I selece View/Source from

IE:

<HTML>
<HEAD>
<title>My Title </title>
<link href="Includes/styles.css" rel="stylesheet">
</HEAD>
<body id="webMainPage">
<form name="_ctl0" method="post" action="." language="javascript"
onsubmit="ValidatorOnSubmit();" id="_ctl0">

<script language="javascript">
function GridRowSelect() {
document.forms[0].elements['myText'].value = 'Deos not work';
document._ctl0.myText.value = 'Doesn't work either'; }
</script>

<TABLE id="Table1">
<tr><td> .
</form>
</body>
</HTML>

All of the javascript code for the grid control is generated within the
<form> tags and it seems to work fine. Would SmartNavigation have

anything
to do with it? Is there any other way I can get at the field in this
scenario?

Thanks in advance,
Denise


Nov 19 '05 #4

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

Similar topics

1
by: Phill Long | last post by:
Right, ok, well I have designed a form that will display a price (22.34) in a text box, and another price in the other text box... I also have a blank text box... Now I want to add both the prices...
15
by: Colin | last post by:
I have a query that calculates the selling price of products on customer orders. Selling prices are calculated based on the average cost of the items when purchased. As I make new purchases, the...
1
by: sandman | last post by:
I've got a simple windows form with some bound textboxes and Save button. Each texbox is bound to column in a table in an Access database. The form fills fine - all the fields show the correct...
4
by: Frank | last post by:
I am loading data through a OleDbDatareader. The load is started from a form by the user, but the actual load is done in a separate class, which is accessed from my form. Now, I want the user to...
1
by: JEgbert | last post by:
I built a dynamic ajax suggest engine, and you would think I could figure this out, but I am having a brain cramp. When I don't have any characters in the search box, it shows a little blip of the...
5
by: rosaryshop | last post by:
I'm working a jewelry/rosary design web site at http://www.rosaryshop.com/rosariesAndKits2.php. As the user makes selections, it updates images of various parts, giving them a preview of the...
3
by: daitasri | last post by:
Hi I am creating a textbox dynamically on click of a button. I want to apply some styles to that textbox using a CSS file. How can i do that using javascript in a HTML page? The following is the...
16
by: Stevo | last post by:
I'm guessing this is a laughably obvious answer to many here, but it's not to me (and I don't have a server or any knowledge of PHP to be able to try it). It's not strictly a PHP question, but...
2
by: =?Utf-8?B?TUNN?= | last post by:
I have an asp.net page that contains an update panel. Within the update panel, controls get added dynamically. During partial page post backs the controls within the panel will change. I have a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...

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.