473,769 Members | 2,103 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with ASP.Net object and Javascript

I have a function:

function SalaryDisplay(m e)
{
var salaryMinLabel = document.getEle mentById("Salar yMin");
salaryMinLabel. value = 200;
alert("after setting salaryMinLabel = " + salaryMinLabel. value);
}

I also have an asp.net object:

<asp:label id="SalaryMin" runat="server" />

Which renders into:

<span id="SalaryMin"> </span>

The function seems to find the span fine. The alert box shows that it is
set to 200. But the web page never shows it.

Is there a problem setting the span element?

Thanks,

Tom
Jul 23 '05 #1
54 4610

"tshad" <ts**********@f tsolutions.com> wrote in message
news:Ow******** **********@news svr21.news.prod igy.com...
I have a function:

function SalaryDisplay(m e)
{
var salaryMinLabel = document.getEle mentById("Salar yMin");
salaryMinLabel. value = 200;
alert("after setting salaryMinLabel = " + salaryMinLabel. value);
}

I also have an asp.net object:

<asp:label id="SalaryMin" runat="server" />

Which renders into:

<span id="SalaryMin"> </span>

The function seems to find the span fine. The alert box shows that it is
set to 200. But the web page never shows it.

Is there a problem setting the span element?
I just change the object to an asp:textbox which renders into an input field
on the screen and this works fine.

In asp, you use a label object to display (and change) text on the screen
that is not part of an input type of field.

Is there a way to do this in Javascript/html?

I just want to be able to display the results of some calculations on a
field that the user inputs as just a label.

Thanks,

Tom
Thanks,

Tom

Jul 23 '05 #2
tshad wrote:
var salaryMinLabel = document.getEle mentById("Salar yMin");
salaryMinLabel. value = 200; <span id="SalaryMin"> </span> Is there a problem setting the span element?


Span elements don't have values. You need to create a new text node then
append it to the element to add text to it. Look at the JavaScript section
of the DOM 1 specification. http://w3.org/DOM/

--
David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #3
I tried to do the same thing with the <lable> label item and had the same
problem. It shows that the value was changed, but it didn't seem to do
anything on the screen:

Yearly Compensation:<i nput name="SalaryMin " type="text" id="SalaryMin"
/>&nbsp;/&nbsp;
<span id="SalaryMax"> </span>
<Label id="SalaryMin2 " for="SalaryMin" >This is a test</Label> />

The javascript code:

function SalaryDisplay(m e)
{
alert("this.val ue = " + me.value);
var salaryMinLabel = document.getEle mentById("Salar yMin2");
salaryMinLabel. innerText = 200;
alert("after setting salaryMinLabel = " + salaryMinLabel. value);
}

This doesn't seem to work. I tried to do it directly
(SalaryMin2.inn erText=200), but that didn't work either.

Tom

"tshad" <ts**********@f tsolutions.com> wrote in message
news:VB******** **********@news svr21.news.prod igy.com...

"tshad" <ts**********@f tsolutions.com> wrote in message
news:Ow******** **********@news svr21.news.prod igy.com...
I have a function:

function SalaryDisplay(m e)
{
var salaryMinLabel = document.getEle mentById("Salar yMin");
salaryMinLabel. value = 200;
alert("after setting salaryMinLabel = " + salaryMinLabel. value);
}

I also have an asp.net object:

<asp:label id="SalaryMin" runat="server" />

Which renders into:

<span id="SalaryMin"> </span>

The function seems to find the span fine. The alert box shows that it is
set to 200. But the web page never shows it.

Is there a problem setting the span element?


I just change the object to an asp:textbox which renders into an input
field on the screen and this works fine.

In asp, you use a label object to display (and change) text on the screen
that is not part of an input type of field.

Is there a way to do this in Javascript/html?

I just want to be able to display the results of some calculations on a
field that the user inputs as just a label.

Thanks,

Tom

Thanks,

Tom


Jul 23 '05 #4

"tshad" <ts**********@f tsolutions.com> wrote in message
news:Ow******** **********@news svr21.news.prod igy.com...
Is there a problem setting the span element?


A 'value' property on span does not display. The newly-created span element
is empty and needs to have a text node appended.

var salaryMinLabel = document.getEle mentById("Salar yMin");
var sMLText = document.create TextNode("200")
salaryMinLabel. appendChild(sML Text);
alert("after setting salaryMinLabel = " +
salaryMinLabel. firstChild.node Value);

nf

Jul 23 '05 #5
"nutso fasst" <no********@no. where> wrote in message
news:db******** **********@news svr21.news.prod igy.com...

"tshad" <ts**********@f tsolutions.com> wrote in message
news:Ow******** **********@news svr21.news.prod igy.com...
Is there a problem setting the span element?


A 'value' property on span does not display. The newly-created span
element
is empty and needs to have a text node appended.

var salaryMinLabel = document.getEle mentById("Salar yMin");
var sMLText = document.create TextNode("200")
salaryMinLabel. appendChild(sML Text);
alert("after setting salaryMinLabel = " +
salaryMinLabel. firstChild.node Value);


Works great.

Is there a way to create the child node at the beginning somehow?

The problem is that as I call this routine It creates another node each
time. I assume the next time I do the document.getEle mentById("Salar yMin")
the child node will still be there (since it was appended to the next time I
did it).

I am confused as to why or how it is working.

The 200 is showing on the screen, but when I do a viewsource, it isn't there
and doesn't seem to be anywhere on the page.

Here is the script from the viewsource of the page:

<script language="javas cript1.4">
function SalaryDisplay(m e)
{
alert("this.val ue = " + me.value);
var salaryMinLabel = document.getEle mentById("Salar yMin");
var sMLText = document.create TextNode("200")
salaryMinLabel. appendChild(sML Text);
SalaryMin2.inne rText = 200;
alert("after setting salaryMinLabel = " +
salaryMinLabel. firstChild.node Value);
}
</script>

Here is the html of the label (span):

&nbsp;&nbsp;Yea rly Compens:<span id="SalaryMin"> </span>&nbsp;/&nbsp;
<span id="SalaryMax"> </span>

As you can see there is no 200 there.

Thanks,

Tom
Jul 23 '05 #6

"tshad" <ts**********@f tsolutions.com> wrote in message
news:HH******** ******@newssvr1 4.news.prodigy. com...
"nutso fasst" <no********@no. where> wrote in message
news:db******** **********@news svr21.news.prod igy.com...

"tshad" <ts**********@f tsolutions.com> wrote in message
news:Ow******** **********@news svr21.news.prod igy.com...
Is there a problem setting the span element?
A 'value' property on span does not display. The newly-created span
element
is empty and needs to have a text node appended.

var salaryMinLabel = document.getEle mentById("Salar yMin");
var sMLText = document.create TextNode("200")
salaryMinLabel. appendChild(sML Text);
alert("after setting salaryMinLabel = " +
salaryMinLabel. firstChild.node Value);


Works great.

Is there a way to create the child node at the beginning somehow?

The problem is that as I call this routine It creates another node each
time. I assume the next time I do the
document.getEle mentById("Salar yMin") the child node will still be there
(since it was appended to the next time I did it).

I am confused as to why or how it is working.

The 200 is showing on the screen, but when I do a viewsource, it isn't
there and doesn't seem to be anywhere on the page.

Here is the script from the viewsource of the page:

<script language="javas cript1.4">
function SalaryDisplay(m e)
{
alert("this.val ue = " + me.value);
var salaryMinLabel = document.getEle mentById("Salar yMin");
var sMLText = document.create TextNode("200")
salaryMinLabel. appendChild(sML Text);
SalaryMin2.inne rText = 200;
alert("after setting salaryMinLabel = " +
salaryMinLabel. firstChild.node Value);
}
</script>

Here is the html of the label (span):

&nbsp;&nbsp;Yea rly Compens:<span id="SalaryMin"> </span>&nbsp;/&nbsp;
<span id="SalaryMax"> </span>

As you can see there is no 200 there.


I figured it out.

I just check to see if the firstchild is null. The script I came up with
is:

<script language="javas cript1.4">
function SalaryDisplay(m e)
{
if(me.id == "WagesMin")
var salaryMinLabel = document.getEle mentById("Salar yMin")
else
var salaryMinLabel = document.getEle mentById("Salar yMax");

if (salaryMinLabel .firstChild == null)
{
var sMLText = document.create TextNode("200") ;
salaryMinLabel. appendChild(sML Text);
}
else
{
salaryMinLabel. firstChild.node Value = 5;
}
}
</script>

This works really well for Span tags.

I have a question on textboxes (input type=text). If I use the above code
and I put the number 12345 in the textbox and then leave the box - it will
put the 200 on top of the 12345 (not instead of). It doesn't get rid of the
12345 before it writes the 200, so the 200 is superimposed ontop of the
12345.

When you try to select the text and it is highlighted, only the 12345 shows.
As soon as you get rid of the selection, then you see the 200 on top of the
12345 (or whatever you changed it to) again.

Is this because that the 12345 is the value and the 200 is something else?

Why is it on top of the 12345 instead of next to it?

Thanks,

Tom
Thanks,

Tom

Jul 23 '05 #7
Ok.

This obviously is not going to work. I spent a lot of time getting this
work correctly and just found that if you go back a page (or forward) and
then go back to the page - all this SPAN information that was just generated
is now gone. Probably related to why it doesn't appear in Viewsource.

Is there a way to make sure it stays with the page?

Thanks,

Tom

"tshad" <ts**********@f tsolutions.com> wrote in message
news:mS******** *******@newssvr 14.news.prodigy .com...

"tshad" <ts**********@f tsolutions.com> wrote in message
news:HH******** ******@newssvr1 4.news.prodigy. com...
"nutso fasst" <no********@no. where> wrote in message
news:db******** **********@news svr21.news.prod igy.com...

"tshad" <ts**********@f tsolutions.com> wrote in message
news:Ow******** **********@news svr21.news.prod igy.com...
Is there a problem setting the span element?

A 'value' property on span does not display. The newly-created span
element
is empty and needs to have a text node appended.

var salaryMinLabel = document.getEle mentById("Salar yMin");
var sMLText = document.create TextNode("200")
salaryMinLabel. appendChild(sML Text);
alert("after setting salaryMinLabel = " +
salaryMinLabel. firstChild.node Value);


Works great.

Is there a way to create the child node at the beginning somehow?

The problem is that as I call this routine It creates another node each
time. I assume the next time I do the
document.getEle mentById("Salar yMin") the child node will still be there
(since it was appended to the next time I did it).

I am confused as to why or how it is working.

The 200 is showing on the screen, but when I do a viewsource, it isn't
there and doesn't seem to be anywhere on the page.

Here is the script from the viewsource of the page:

<script language="javas cript1.4">
function SalaryDisplay(m e)
{
alert("this.val ue = " + me.value);
var salaryMinLabel = document.getEle mentById("Salar yMin");
var sMLText = document.create TextNode("200")
salaryMinLabel. appendChild(sML Text);
SalaryMin2.inne rText = 200;
alert("after setting salaryMinLabel = " +
salaryMinLabel. firstChild.node Value);
}
</script>

Here is the html of the label (span):

&nbsp;&nbsp;Yea rly Compens:<span id="SalaryMin"> </span>&nbsp;/&nbsp;
<span id="SalaryMax"> </span>

As you can see there is no 200 there.


I figured it out.

I just check to see if the firstchild is null. The script I came up with
is:

<script language="javas cript1.4">
function SalaryDisplay(m e)
{
if(me.id == "WagesMin")
var salaryMinLabel = document.getEle mentById("Salar yMin")
else
var salaryMinLabel = document.getEle mentById("Salar yMax");

if (salaryMinLabel .firstChild == null)
{
var sMLText = document.create TextNode("200") ;
salaryMinLabel. appendChild(sML Text);
}
else
{
salaryMinLabel. firstChild.node Value = 5;
}
}
</script>

This works really well for Span tags.

I have a question on textboxes (input type=text). If I use the above code
and I put the number 12345 in the textbox and then leave the box - it will
put the 200 on top of the 12345 (not instead of). It doesn't get rid of
the 12345 before it writes the 200, so the 200 is superimposed ontop of
the 12345.

When you try to select the text and it is highlighted, only the 12345
shows. As soon as you get rid of the selection, then you see the 200 on
top of the 12345 (or whatever you changed it to) again.

Is this because that the 12345 is the value and the 200 is something else?

Why is it on top of the 12345 instead of next to it?

Thanks,

Tom
Thanks,

Tom


Jul 23 '05 #8

"tshad" <ts**********@f tsolutions.com> wrote in message
news:FW******** **********@news svr13.news.prod igy.com...
Is there a way to make sure it stays with the page?


The span tag is being created server-side (runat=server); that is the
'source' you view. Content changes you make client-side do not automatically
go back to the source, and they are not automatically saved/restored if you
switch to another page and then return. You could create a framed site and
save all current values for each page in variables in the top frame. I don't
know about .net, but suppose there is a database connector. Suggest you try
a Microsoft .net newsgroup.

nf
Jul 23 '05 #9
tshad wrote:
Ok.

Please don't top-post - read the group FAQ:

<URL:http://www.jibbering.c om/faq/#FAQ2_3>
This obviously is not going to work. I spent a lot of time getting this
work correctly and just found that if you go back a page (or forward) and
then go back to the page - all this SPAN information that was just generated
is now gone. Probably related to why it doesn't appear in Viewsource.
The page source is what was loaded from the server. Whatever you do
locally with scripting does not change the source any more than
modifying a photocopy changes the original.

Some information from history pages may be saved in cache by browsers
and used when the page is re-visited, but that mostly applies to data
entered into forms fields. Even then, you should not depend on this
behaviour being consistent across browsers. I don't think any
browser will cache changes made by scripts.

Is there a way to make sure it stays with the page?


This infers that you wish to maintain state somehow. Various methods
exist, such as storing user selections in a cookie or sending data
back to the server and then reconstructing the page when the user
re-visits. But that takes serious programming effort at both client
and server since the web is stateless and you are attempting to make
it otherwise.

[...]
--
Rob
Jul 23 '05 #10

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

Similar topics

5
6089
by: Justice | last post by:
Currently I'm doing some experimenting with the XMLHTTP object in Javascript. Now, the XMLHttp object is asynchronous (at least in this case), and the following code causes a significant memory loss even though I seem to be allocaitng everything; help would be *vastly* appreciated. What am I doing wrong here? I thought I was doing everything correctly (setting things to null, for example) but none of the memory seems to get replaced. ...
5
1549
by: Shawn Modersohn | last post by:
For the script: <script language="JavaScript"> function pullPage(){ var arrayLength=document.teamSelectionF.teamSelectionS.length; var pageNav = new Array(arrayLength); var gotoNum=document.teamSelectionF.teamSelectionS.options.value; pageNav="http://www.tandtsports.com"; pageNav="http://www.tandtsports.com/Cougars.html";
55
4214
by: drhowarddrfine | last post by:
I'm working on a web site that could use some control using js but am concerned about what problems I may have with potential users having their js turned off. Has anyone had any serious problems with this sort of thing? I know some of these potential users are with big companies and am wondering if anyone had real problems with that.
10
19176
by: Danny | last post by:
Hi all, I am having some odd problems with AJAX on Firefox (1.5). When I use GET as the request method everything works ok, but when I do a POST the remote function doesn't get the parameters I am passing to it. Everything works fine on IE 6. Here's a couple samples of what I am doing: // using GET url = 'http://www.myserver.com/cgi-bin/funct?key1=value1&key2=value2'
2
2097
by: beseecher | last post by:
Hi, In my research in the javascript language I have encountered problems with implementing prototype inheritance while preserving private methods functioning properly. Here is an example: function A(){ var _this = this; this.a = 10;
1
4953
by: Bob | last post by:
Hi, Hope you can help me with this one. I'm at my wits end. I'm trying to create an intelligent edit-box like the excellent "Customer" one at the URL: http://munich.schwarz-interactive.de/autocomplete.aspx
1
3426
by: kevin.a.sweeney | last post by:
I would like to open an application from a hyperlink on a webpage. 1. the webpage is located on my local machine. 2. the application is located on my local machine. 3. the application will run on my local machine. In other words... The WEB is really not involved. What I have so far works with a Netscape Browser but what I really need is for it to work in the IE browser or one that I will create
14
2817
by: julie.siebel | last post by:
I've been wrestling with a really complex page. All the data is drawn down via SQL, the page is built via VBScript, and then controlled through javascript. It's a page for a travel company that shows all the properties, weeks available, pricing, etc. for a particular area of Europe. The data varies widely depending on the region; at times there will be 50 properties, and at other times only a half dozen. The cross referencing of...
1
1863
RMWChaos
by: RMWChaos | last post by:
I grabbed this "Rock Solid addEvent" code from this site, which is based on Mark Wubben's event-cache code. (These links for reference only.) I am having two problems with it, and the webmaster is s...l...o...w to respond. So I thought I would ask about it here. If I knew more about how this code works, I could probably figure out most of the problems myself, but with this one, I am clueless! =D First question: This may be my own...
10
1853
by: jodleren | last post by:
Hi I know, that there are a lot of people having problems with orkut.com, errors like "object expected" and named objects missing. When loading the site can generate some 10 errors, and still just leave a blue page - seems like it heavily rely on JS. Still, me and friends having problems and orkut seems just to ignore it. I am sure, that other poeple have problems, and I really wonder what
0
10199
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
9850
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
8862
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
7396
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
6662
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
5293
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...
0
5436
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3948
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
3551
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.