G
Guest
I have developed a web form by using visual Studio. My question is:
(1) what is the problem?
(2) what is right way to do it?
In the form, there are labels with id:
lblWear, lblColor, and lblQuality.
Now I need to assign values to those label dynamically.
I have JavaScript:
function regTriples(id){
if (id==1){
document.Form1.lblWear.value="Shirt";
document.Form1.lblColor.value="Brown";
document.Form1.lblQuality.value="Honesty";
}
else if (id==2){
document.Form1.lblWear.value="Shoes";
document.Form1.lblColor.value="Black";
document.Form1.lblQuality.value="Modesty";
}
else if (id==3){
document.Form1.lblWear.value="Socks";
document.Form1.lblColor.value="Blue";
document.Form1.lblQuality.value="Charity";
}
}
When I click button which enables the JavaScript and assign those perdefined
values to the Labels, I got error from the bottom coner of the webbrowser IE:
"document.Form1.lblWear.value is null or not an object"
The following HTML code is from the source of web browser, which is
generated by web form .aspx file on the server. The default values have been
assigned when label control created on the webform.
<span id="lblWear" style="font-size:12pt;Z-INDEX: 160; LEFT: 32px; POSITION:
absolute; TOP: 232px">Shirt</span><span id="lblColor"
style="font-size:12pt;Z-INDEX: 161; LEFT: 32px; POSITION: absolute; TOP:
256px">Brown</span><span id="lblQuality" style="font-size:12pt;Z-INDEX: 162;
LEFT: 32px; POSITION: absolute; TOP: 280px">Honesty</span>
Thanks
David
(1) what is the problem?
(2) what is right way to do it?
In the form, there are labels with id:
lblWear, lblColor, and lblQuality.
Now I need to assign values to those label dynamically.
I have JavaScript:
function regTriples(id){
if (id==1){
document.Form1.lblWear.value="Shirt";
document.Form1.lblColor.value="Brown";
document.Form1.lblQuality.value="Honesty";
}
else if (id==2){
document.Form1.lblWear.value="Shoes";
document.Form1.lblColor.value="Black";
document.Form1.lblQuality.value="Modesty";
}
else if (id==3){
document.Form1.lblWear.value="Socks";
document.Form1.lblColor.value="Blue";
document.Form1.lblQuality.value="Charity";
}
}
When I click button which enables the JavaScript and assign those perdefined
values to the Labels, I got error from the bottom coner of the webbrowser IE:
"document.Form1.lblWear.value is null or not an object"
The following HTML code is from the source of web browser, which is
generated by web form .aspx file on the server. The default values have been
assigned when label control created on the webform.
<span id="lblWear" style="font-size:12pt;Z-INDEX: 160; LEFT: 32px; POSITION:
absolute; TOP: 232px">Shirt</span><span id="lblColor"
style="font-size:12pt;Z-INDEX: 161; LEFT: 32px; POSITION: absolute; TOP:
256px">Brown</span><span id="lblQuality" style="font-size:12pt;Z-INDEX: 162;
LEFT: 32px; POSITION: absolute; TOP: 280px">Honesty</span>
Thanks
David