Hi, try to put this in the JS box
Cheers
Max
window.addEvent('domready', function() {
//function code goes here : e.g: alert('page loaded');
});
Cheers
Max
This is what I have for JS:
I want the setup() function to run when the page loads. Where do I add that line of code and do I put just the setup function in there?
function nullOptions(aMenu){
var tot=aMenu.options.length
for (i=0;i<tot;i++)
{
aMenu.options[i]=null
}
aMenu.options.length=0;
}
function occupation0(aMenu){
nullOptions(aMenu)
with (aMenu){
//Rewrites the text and values
options[0]=new Option("Select a branch","none");
options[1]=new Option("Orthopedic Surgeon");
options[2]=new Option("Neurosurgeon");
options[3]=new Option("Cardiovascular Surgeon");
options[4]=new Option("Primary Care");
options[5]=new Option("Pediatrician");
options[6]=new Option("Radiologist");
options[7]=new Option("Anesthesiologist");
options[0].selected=true
}
}
function occupation1(aMenu){
nullOptions(aMenu)
with (aMenu){
//Rewrites the text and values
options[0]=new Option("Select a branch","none");
options[1]=new Option("Physician's Assistant");
options[2]=new Option("Nurse Practitioner");
options[3]=new Option("Registered Nurse");
options[4]=new Option("Orthotist");
options[5]=new Option("Pharmtech");
options[0].selected=true
}
}
function occupation2(aMenu){
nullOptions(aMenu)
with (aMenu){
//Rewrites the text and values
options[0]=new Option("Select a branch","none");
options[1]=new Option("Surgical");
options[2]=new Option("Radiology");
options[3]=new Option("Phlebotomy");
options[0].selected=true
}
}
/* ####################### setUp ####################### */
function setUp(){
with (document.formDoubleMenu) {
if (menuOccupations.selectedIndex==0){
menuOccupations.options[0].selected=true
menuBranches.options[0].selected=true
}
if (menuOccupations.selectedIndex==1)
occupation0(menuBranches)
if (menuOccupations.selectedIndex==2)
occupation1(menuBranches)
if (menuOccupations.selectedIndex==3)
occupation2(menuBranches)
}
}
/* ####################### changeBranches ####################### */
function changeBranches(){
aMenu=document.Appleton_West.menuOccupations
aMenu2=document.Appleton_West.menuBranches
with (aMenu){
switch (selectedIndex) {
case 0:
aMenu2.options.length=0;
aMenu2.options[0]=
new Option("Branches appear here","none")
aMenu2.options[0].selected=true;
history.go(0)
break
case 1:
occupation0(aMenu2)
aMenu2.options[0].text="Occupation: Physician"
break
case 2:
occupation1(aMenu2)
aMenu2.options[0].text="Occupation: Midlevel"
break
case 3:
occupation2(aMenu2)
aMenu2.options[0].text="Occupation: Tech"
break
}}}
I want the setup() function to run when the page loads. Where do I add that line of code and do I put just the setup function in there?
I answered my last question already but I was able to make everything work in Dreamweaver but when I enter it into chronoforms through joomla it doesn't work! What can I do?!?!
Hi arkmedia,
whats : formDoubleMenu in your code means ? is this the form name in the original code ?
whats : formDoubleMenu in your code means ? is this the form name in the original code ?
Yes i took the code from another form I had, but I corrected the that and it still doesn't work
Here is my code, it works fine in dreamweaver:
Here is my code, it works fine in dreamweaver:
window.addEvent('domready', function setUp() {
with (document.Appleton_West) {
if (menuOccupations.selectedIndex==0){
menuOccupations.options[0].selected=true
menuBranches.options[0].selected=true
}
if (menuOccupations.selectedIndex==1)
occupation0(menuBranches)
if (menuOccupations.selectedIndex==2)
occupation1(menuBranches)
if (menuOccupations.selectedIndex==3)
occupation2(menuBranches)
}
});
function nullOptions(aMenu){
var tot=aMenu.options.length
for (i=0;i<tot;i++)
{
aMenu.options[i]=null
}
aMenu.options.length=0;
}
function occupation0(aMenu){
nullOptions(aMenu)
with (aMenu){
//Rewrites the text and values
options[0]=new Option("Select a branch","none");
options[1]=new Option("Orthopedic Surgeon");
options[2]=new Option("Neurosurgeon");
options[3]=new Option("Cardiovascular Surgeon");
options[4]=new Option("Primary Care");
options[5]=new Option("Pediatrician");
options[6]=new Option("Radiologist");
options[7]=new Option("Anesthesiologist");
options[0].selected=true
}
}
function occupation1(aMenu){
nullOptions(aMenu)
with (aMenu){
//Rewrites the text and values
options[0]=new Option("Select a branch","none");
options[1]=new Option("Physician's Assistant");
options[2]=new Option("Nurse Practitioner");
options[3]=new Option("Registered Nurse");
options[4]=new Option("Orthotist");
options[5]=new Option("Pharmtech");
options[0].selected=true
}
}
function occupation2(aMenu){
nullOptions(aMenu)
with (aMenu){
//Rewrites the text and values
options[0]=new Option("Select a branch","none");
options[1]=new Option("Surgical");
options[2]=new Option("Radiology");
options[3]=new Option("Phlebotomy");
options[0].selected=true
}
}
/* ####################### changeBranches ####################### */
function changeBranches(){
aMenu=document.Appleton_West.menuOccupations
aMenu2=document.Appleton_West.menuBranches
with (aMenu){
switch (selectedIndex) {
case 0:
aMenu2.options.length=0;
aMenu2.options[0]=
new Option("Branches appear here","none")
aMenu2.options[0].selected=true;
history.go(0)
break
case 1:
occupation0(aMenu2)
aMenu2.options[0].text="Occupation: Physician"
break
case 2:
occupation1(aMenu2)
aMenu2.options[0].text="Occupation: Midlevel"
break
case 3:
occupation2(aMenu2)
aMenu2.options[0].text="Occupation: Tech"
break
}}}
I can't give hints because this code is meaningless to me without seeing the other form you had with elements...etc, you need to get Firefox with Firebug extension and while you are viewing your form which doesn't work, check for JS errors and this will tell you where to fix your code problems!
cheers
Max
cheers
Max
This topic is locked and no more replies can be posted.