Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Newbie question
- From: schalk at volume4.com (Schalk)
- Subject: [Javascript] Newbie question
- Date: Sat Dec 3 08:44:06 2005
Greetings All
No worries, I figured it out. For those who would be interested in the
code it follows below. If anyone has any advice on improving the script
please let me know.
function shf_init() {
// get array of radio buttons to recursively attach the event listener
// and trigger the showHideFieldset function.
var payment_type = document.forms[0].payment_type;
// get specific fieldsets to show hide
var show_c = document.getElementById("c-info");
var show_cc = document.getElementById("cc-info");
show_c.style.display = "none";
show_cc.style.display = "none";
if(navigator.appVersion.indexOf("MSIE")) {
for(var i=0;i<payment_type.length;i++) {
payment_type[i].attachEvent('onclick',showHideFieldset);
}
} else {
for(var i=0;i<payment_type.length;i++) {
payment_type[i].addEventListener('click',showHideFieldset,false);
}
}
}
function showHideFieldset() {
// get specific radio buttons to check for the checked property
var radio_c = document.getElementById("payment_type2");
var radio_cc = document.getElementById("payment_type3");
// get specific fieldsets to show hide
var show_c = document.getElementById("c-info");
var show_cc = document.getElementById("cc-info");
if(radio_c.checked) {
show_c.style.display = "block";
show_cc.style.display = "none";
} else if(radio_cc.checked) {
show_cc.style.display = "block";
show_c.style.display = "none";
}
}
window.onload=function(){
shf_init();
// add other functions here.
}
--
Kind Regards
Schalk Neethling
Web Developer.Designer.Programmer.President
Volume4.Business.Solution.Developers
- Follow-Ups:
- [Javascript] Newbie question
- From: Schalk
- [Javascript] Newbie question
- References:
- [Javascript] Newbie question
- From: Schalk
- [Javascript] Newbie question
- From: Roger Roelofs
- [Javascript] Newbie question
- From: Schalk
- [Javascript] Newbie question
- Prev by Date: [Javascript] Newbie question
- Next by Date: [Javascript] Newbie question
- Previous by thread: [Javascript] Newbie question
- Next by thread: [Javascript] Newbie question
- Index(es):