PDA

View Full Version : Accept Terms submit button adding??



jrheeder
06-04-2008, 10:06 PM
Hi there,

I recently added the script mentioned below
"Accept terms" form submission (http://www.dynamicdrive.com/dynamicindex16/acceptterm.htm).

Now I would like to add two diffent button styles to my submit button.
First when the button is Enabled the class is called style1
Secnd when the button is Disabled the class is called style1_alt

Is this possible to add to the script show in that tutorial?:eek:

rangana
06-05-2008, 12:42 AM
Add the highlighted:


function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){ //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="submit")
tempobj.disabled=!checkobj.checked
tempobj.className=(tempobj.disabled==true)?'style1_alt':'style1';
}
}
}


Make sure you have declared it in your CSS already:


.style1{background:#eee;}
.style1_alt{background:#fc0;}


See if it helps.

jrheeder
06-05-2008, 06:54 AM
Add the highlighted:


function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){ //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="submit")
tempobj.disabled=!checkobj.checked
tempobj.className=(tempobj.disabled==true)?'style1_alt':'style1';
}
}
}


Make sure you have declared it in your CSS already:


.style1{background:#eee;}
.style1_alt{background:#fc0;}


See if it helps.

Thank you for the advice. . . Inplimented this script, but one issue occurs during this process when I check the checkbox, it seems to change all my other elements (like my input boxes and dropdown boxes) class (CSS style for input elements) field. So it change any field in the form that has a class attached to it. Can you tell me why this is?

rangana
06-05-2008, 07:02 AM
See if enclosing them in a bracket helps:


function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){ //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="submit"){
tempobj.disabled=!checkobj.checked
tempobj.className=(tempobj.disabled==true)?'style1_alt':'style1';}
}
}
}

jrheeder
06-05-2008, 07:06 AM
See if enclosing them in a bracket helps:


function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){ //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="submit"){
tempobj.disabled=!checkobj.checked
tempobj.className=(tempobj.disabled==true)?'style1_alt':'style1';}
}
}
}


That solveed the issue encapsulating it Thank you sooo much:):D