473,396 Members | 2,059 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,396 software developers and data experts.

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.srcElement.value == "starter")
typedesc.innerHTML="A Starter request is for a new employee who's
never worked for cadbury or the Bottling Group before.";
' if (window.event.srcElement.value == "leaver")
typedesc.innerHTML="A Leaver request is for an existing employee who's
permanently leaving the company.";
'}

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

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

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

</script>

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

....
<td class="layout bold">
<input type="radio" name="reqtype" value="starter"
checked="checked" onclick="describetype(starter)"Starter<br>
<input type="radio" name="reqtype" value="leaver"
onclick="describetype(leaver)"Leaver<br />
</td>
<td class="layout bold">
<input type="radio" name="reqtype" value="mover"Mover<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 1616
wrote on 27 feb 2007 in comp.lang.javascript:
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.netwrote:
wrote on 27 feb 2007 in comp.lang.javascript:
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="emptype(this)">
<option value=" "</option>
<option value="employee">Employee</option>
<option value="contractor">Contractor</option>
</select><br>
<img src="img/spacer_white.gif" width=30 height=1>
<div id=conttype class="hide">
<select name="contracttype">
<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("Contractor selected");

// Here's what I tried before - didn't work either...
//o = document.getElementsByName("emptype");
//if (o.selectedIndex = 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.javascript:
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.netwrote:
wrote on 01 mrt 2007 in comp.lang.javascript:
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.javascript:
On Mar 2, 2:20 am, "Evertjan." <exjxw.hannivo...@interxnl.netwrote:
> wrote on 01 mrt 2007 in comp.lang.javascript:
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
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....
3
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...
1
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...
9
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
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
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...
2
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...
3
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...
1
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 ...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
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...
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...
0
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,...

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.