[Javascript] Newbie question
Schalk
schalk at volume4.com
Sat Dec 3 08:43:53 CST 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
More information about the Javascript
mailing list