473,804 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically changing a DIV

I'm pulling my hair out...

I have a few radio boxes where a user can choose different options and
I want to show an explanation of each option after it's clicked.
Here's what I have:

<script type="text/JavaScript">

function toggle(o){
o.className = ( o.className == "show" ) ? "hide" : "show";
}

'function describetype(){
' if (window.event.s rcElement.value == "starter")
typedesc.innerH TML="A Starter request is for a new employee who's
never worked for cadbury or the Bottling Group before.";
' if (window.event.s rcElement.value == "leaver")
typedesc.innerH TML="A Leaver request is for an existing employee who's
permanently leaving the company.";
'}

'function starter(){
'typedesc.inner HTML="A Starter request is for a new employee who's
never worked for cadbury or the Bottling Group before.";
'}

'function leaver(){
'typedesc.inner HTML="A Leaver request is for an existing employee
who's permanently leaving the company.";
'}

function describetype(o) {
if (o == "starter"){
typedesc.innerH TML="Starters are...etc.";
}
if (o == "leaver"){
typedesc.innerH TML="Leavers are...etc.";
}
}

</script>

The first "toggle" function works fine but the "describety pe" won't
work. Here's the HTML:

....
<td class="layout bold">
<input type="radio" name="reqtype" value="starter"
checked="checke d" onclick="descri betype(starter) "Starter<br >
<input type="radio" name="reqtype" value="leaver"
onclick="descri betype(leaver)" Leaver<br />
</td>
<td class="layout bold">
<input type="radio" name="reqtype" value="mover"Mo ver<br />
<input type="radio" name="reqtype" value="adhoc"Ad Hoc
</td>
....

The error keeps saying that "starter" or "leaver" is undefined. I'm
not much of a javascript guy (mostly the cut and paste variety myself)
but everything I've seen says this should work. No?

Keith

Feb 27 '07 #1
7 1638
wrote on 27 feb 2007 in comp.lang.javas cript:
I have a few radio boxes where a user can choose different options and
I want to show an explanation of each option after it's clicked.
Here's what I have:

<script type="text/JavaScript">

function toggle(o){
o.className = ( o.className == "show" ) ? "hide" : "show";
}

'function describetype(){
The apostrophe ' is a vbs remark character,
javasctipt uses //

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 27 '07 #2
On Feb 27, 9:31 am, "Evertjan." <exjxw.hannivo. ..@interxnl.net wrote:
wrote on 27 feb 2007 in comp.lang.javas cript:
The apostrophe ' is a vbs remark character,
javasctipt uses //
Ok lesson #1 learned. I changed the comment characters and it still
didn't work but I switched to the ridiculously simple "starter" and
"leaver" functions and that finally works. I wish I knew why it kept
failing but time is more valuable than in-depth knowledge at this
point. :)

Thanks,

Keith

Feb 27 '07 #3
Ok I'm still trying to work on the same form and display a div based
on a select statement and nothing I do seems to work.

I'm trying to make a drop down select list that will display another
list when I choose the second option. Here's the lists:

<B>Employment Type</B>
<select name="emptype" onchange="empty pe(this)">
<option value=" "</option>
<option value="employee ">Employee</option>
<option value="contract or">Contracto r</option>
</select><br>
<img src="img/spacer_white.gi f" width=30 height=1>
<div id=conttype class="hide">
<select name="contractt ype">
<option value=" "</option>
<option value="payroll" >Payroll</option>
<option value="agency"> Agency</option>
</select><br />
</div>

If they choose "contractor " in the first list, I want a second
dropdown to choose "Payroll" or "Agency".

Here's the code I've got - again it's 99% copied and pasted so I'm
thinking there's probably a syntax error or something:

<script type="text/JavaScript">

function toggle(o){
o.className = ( o.className == "show" ) ? "hide" : "show";
}

function emptype(o){
// This one just alerts me as a test. Even this doesn't work.
var pick = o.options[o.selectedIndex].value;
if (pick == "contractor ") alert("Contract or selected");

// Here's what I tried before - didn't work either...
//o = document.getEle mentsByName("em ptype");
//if (o.selectedInde x = 2)
// toggle(conttype );
}

</script>

Thanks,

Keith

Mar 1 '07 #4
I think I solved my own problems. I had form objects named the same
thing as functions in both cases and once I changed the names, it all
worked like gangbusters. I assumed objects and functions were
exclusive and it wouldn't matter... Lesson #2. :)

Keith

Mar 1 '07 #5
wrote on 01 mrt 2007 in comp.lang.javas cript:
I think I solved my own problems. I had form objects named the same
thing as functions in both cases and once I changed the names, it all
worked like gangbusters. I assumed objects and functions were
exclusive and it wouldn't matter... Lesson #2. :)
Without quoting we wouldn't know what you are talking about.

This is usenet!

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 2 '07 #6
On Mar 2, 2:20 am, "Evertjan." <exjxw.hannivo. ..@interxnl.net wrote:
wrote on 01 mrt 2007 in comp.lang.javas cript:
I think I solved my own problems. I had form objects named the same
thing as functions in both cases and once I changed the names, it all
worked like gangbusters. I assumed objects and functions were
exclusive and it wouldn't matter... Lesson #2. :)

Without quoting we wouldn't know what you are talking about.

This is usenet!
Surely 99% of people use a news reader that keeps threads together...

Anyway thanks again. :)

Keith
Mar 2 '07 #7
wrote on 02 mrt 2007 in comp.lang.javas cript:
On Mar 2, 2:20 am, "Evertjan." <exjxw.hannivo. ..@interxnl.net wrote:
> wrote on 01 mrt 2007 in comp.lang.javas cript:
I think I solved my own problems. I had form objects named the same
thing as functions in both cases and once I changed the names, it all
worked like gangbusters. I assumed objects and functions were
exclusive and it wouldn't matter... Lesson #2. :)

Without quoting we wouldn't know what you are talking about.

This is usenet!

Surely 99% of people use a news reader that keeps threads together...
How do you know?

You cannot, since the reader is not the point.

Individual posts do not arrive syngronised on each news server, nor can you
be sure they are kept there for a reasonable time.

Furthermore it is polite "Usenet Netiquette" to edit the quotes to the
essentials that are needed to understand the thread.
Anyway thanks again. :)
You are welcome.
But why again?
Did you already know the advice?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 2 '07 #8

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

Similar topics

2
1953
by: Satish Kumar Chimakurthi | last post by:
Hi all, An external solver program is dynamically producing files with different names 0000001.dat, 0000002.dat, 0000003.dat etc.....at regular intervals. These files contain all numeric data. Is it possible to read each of these dynamically in python ?? If so, how should my code look like ?? If it was not dynamically required, then, I would change the name of the file in my *open* statement every time and read the corresponding one. But...
3
2997
by: lanky_tx | last post by:
Hi All, We have an automated build and test environment using NAnt and Nunit. Some of our assemblies are being strong named by modifying the AssemblyInfo.cs and having csc compile it. Some of these strong named assemblies are being dynamically loaded into the runtime. We store the metadata information about the strong named assemblies in a config file. Metadata in the config file looks like this:
1
2221
by: Dennis Marks | last post by:
I have a page with 3 divisions overlaying each other. I dynamically change the visibility to switch between them. On the Mac version of IE 5.1 I am not able to activate the scroll bars after making a division visible. Only the originally displayed division works. I am able to click on the data (option select lists) in all of the divisions. There is no problem when I use Netscape. I would like to dynamically change the z-index to see if...
9
3733
by: pablo | last post by:
Dear NGers, I would like to change the alt-text with the changing of the image during a mouseover action. Can document.images.altView be changed dynamically? TIA, pablo
5
9774
by: Angel | last post by:
Is there a way to create an IFRAME dynamically via VB.NET. In other words creating the HTML element in the server side code? thanks in advance....
5
1466
by: Tascien | last post by:
I was able to build an asp page dynamically depending on the question that the user answered through the online wizard... I think i can dynamically also create '.vb' or '.aspx' dynamically depending on the answers that users entered in the online wizard... the only issue here, is that, once the wizard created the asp page, the online visitors could then request the page, and execute it w/no problem, and be able to use embended dynamic...
2
7000
by: John | last post by:
Hi Everyone, I have a question about dynamically changing the length of a varchar(n) field, in case the value I'm trying to insert is too big and will give a "truncated" error, but before the error is given! i.e. Is there some kind of a way to "test" the length of the field while Inserting the value into it, and to have it automatically increase its length to the length of the value being inserted, in case the value is too big? I've...
3
3039
by: ICPooreMan | last post by:
The following is a very simple example of what I want to do take an elements oncontextmenu and changing it dynamically onclick of that same element. The code below will fail unless you change the line document.getElementById('div1').setAttribute('oncontextmenu', someText); to document.getElementById('div1').setAttribute('oncontextmenu', function(){alert('World World');return false;});
1
1522
by: hellohi | last post by:
Hello Everyone, I wanted to change the existing variable names dynamically.( like www.aol.com ) in this site images and some text is changing dynamically. like wise i need javascrip to write Thanks in advance
2
1307
missshaikh
by: missshaikh | last post by:
hi friends I am programming a website which will include ad banners. The requirements are that the banners will be dynamically changing for each page. By this I mean that if there are ten banners in total and each page will always have two banners. So that two of the ten banners will be randomly selected and placed in the webpage. I have this part figured out. the problem I am facing is that they want to have the ability that banner...
0
9711
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10595
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
10335
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
10088
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
9169
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
7633
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
5529
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...
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
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.