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

How to get DIV to work like LAYER?

Hi there,

How to get DIV to work like LAYER?
How can I get the following script to work?
I am trying to get text to appear in a div tag as a result of the selection
a dropdown list.
I have indicated the problem area with //???

Please help a newbie.
Thanks.

<html><head>
<Title>Targeting Text to Layer(Div)</Title>
<script language="JavaScript">
<!--
var selectedNumber;
var myText="Choose a number:";

function changeText(selectedNumber){
//??????
//document.mylayer.write ("You chose: " + selectedNumber);
// or maybe..
//myText="You chose: " + selectedNumber;
//??????
}
//-->
</script>
</head>

<body>
<p>Testing...</p>

<script language="JavaScript">
document.write('<DIV name="mylayer" ID="mylayer">' + myText + '</div>');
</script>

<select name="myselect" onChange="changeText(myselect.value)">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>

</body>
</html>

Jul 20 '05 #1
1 1286
Lee
altergothen said:

Hi there,

How to get DIV to work like LAYER?
How can I get the following script to work?
I am trying to get text to appear in a div tag as a result of the selection
a dropdown list.
I have indicated the problem area with //???


Note that the way you were accessing the value of the Select
object wouldn't work in all browsers.

<html>
<head>
<Title>Targeting Text to Layer(Div)</Title>
<script type="text/javascript">
//var selectedNumber; You don't need to declare formal parameters.
var myText="Choose a number:";
function changeText(selectedNumber){
document.getElementById("mylayer").innerHTML="You chose: "
+selectedNumber;
}
</script>
</head>

<body>
<p>Testing...</p>

<script type="text/javascript">
document.write('<DIV name="mylayer" ID="mylayer">' + myText + '</div>');
</script>

<select name="myselect" onChange="changeText(options[selectedIndex].value)">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>

</body>
</html>

Jul 20 '05 #2

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

Similar topics

0
by: digilab | last post by:
Hi Anyone know how work with xml like that one ? I want to add a new feature - make picture black and whit in layer 1 .... <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE CTSFile SYSTEM...
2
by: SabMan | last post by:
I understand that document.layers is no longer supported in Netscape 7.1 but I am not sure on how to fix the code so that it will work with Netscape 7.1. I understand that document.all is no...
2
by: Stephan | last post by:
Hi everyone. I'm using Macromedia's " function MM_showHideLayers() " to show a layer, triggered by an image in the body of the file on load: <IMG height=380 src="images/verybg.gif" width=185...
8
by: Cat | last post by:
Greetings, I have an old javascript effect that was running on some of my sites for quite long, working fine in Netscape (up to 4.75) and IE. It still works in the newer IEs, but not in the new...
9
by: kernelxu | last post by:
hi, everyone. now, I'am confused on such a problem: function setbuf(stdin, NULL) or setvbuf(stdin, NULL, _IONBF, 0) can set the stadard input stream unbuffered. however, why does my program...
2
by: shan chennai | last post by:
hi... i have a design as follows... Presentation Layer (.aspx, .cs) -- Service Layer (just a facade) -- Business Layer (business objects) -- Data Layer (all DB related things for business...
2
by: dkode | last post by:
Hello, I am laying out the architecture for a very large website that will scale to a very large degree. I have a couple of questions before I attempt to go and implement a Broker/Persistence...
1
by: rbg | last post by:
Hi, I am trying to understand the layering concept with the ASP.NET 2.0 apps. I have a ASP.NET 2.0 Web app which has 3 layers Presentation layer which contains UI elements and Input...
16
by: MS newsgroup | last post by:
I don't have clear reasons why we need business logic layer and data logic layer instead of having only data logic layer. Are there any good reasons for that?
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
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
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...

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.