Need help enabling/disabling radio buttons onclick. (solved)
Solved - Figured it out.
I have a form where there are two options: Edit, and Delete. If the user selects delete, I want all of the form options of be disabled. If the user selects delete, and then selects edit I want all of the form options to be enabled again.
I cannot get this work. I'm a beginner with a JavaScript so if someone could help me out here and tell me why this is not working I'd really appreciate it.
Sorry about the format below. It's inside of a PHP echo "" and I had to \" -> " to make it looks like HTML. Not sure why the form isn't line breaking where it breaks in my script.
Solved - Figured it out.
I have a form where there are two options: Edit, and Delete. If the user selects delete, I want all of the form options of be disabled. If the user selects delete, and then selects edit I want all of the form options to be enabled again.
I cannot get this work. I'm a beginner with a JavaScript so if someone could help me out here and tell me why this is not working I'd really appreciate it.
Sorry about the format below. It's inside of a PHP echo "" and I had to \" -> " to make it looks like HTML. Not sure why the form isn't line breaking where it breaks in my script.
PHP:
echo "
<script language=\"javascript\">
<!-- //
function setEnablePass(obj) {
if(obj.value == \"enable_pass\") {
document.settings.current_pass.disabled = 0;
document.settings.new_pass.disabled = 0;
document.settings.new_pass_c.disabled = 0;
}
}
function setEnableEmail(obj) {
if(obj.value == \"enable_email\") {
document.settings.current_email.disabled = 0;
document.settings.new_email.disabled = 0;
document.settings.new_email_c.disabled = 0;
}
}
function setEnablePub(obj) {
if(obj.value == \"enable_pub\") {
document.settings.publicity.disabled = 0;
}
}
function setEnableNL(obj) {
if(obj.value == \"enable_nl\") {
document.settings.newsletter.disabled = 0;
}
}
// -->
</script>
<div class=\"form\">
<form name=\"settings\" action=\"m_asettings.htm\" method=\"post\">
<u>Check Below to Change</u><br /><br />
<input type=\"checkbox\" name=\"pass_change\" value=\"enable_pass\" onclick=\"setEnablePass(this)\"> Change Password<br />
<input type=\"checkbox\" name=\"email_change\" value=\"enable_email\" onclick=\"setEnableEmail(this)\"> Change Email Address<br />
<input type=\"checkbox\" name=\"publicity_change\" value=\"enable_pub\" onclick=\"setEnablePub(this)\"> Change Account Publicity<br />
<input type=\"checkbox\" name=\"newsletter_change\" value=\"enable_nl\" onclick=\"setEnableNL(this)\"> Change Email List Status<br /><br />
<hr />
<br />
<input class=\"form\" type=\"password\" disabled=\"disabled\" name=\"current_pass\" /><span style=\"font-size:10px;\"> (Current password)<br />
<input class=\"form\" type=\"password\" disabled=\"disabled\" name=\"new_pass\" /><span style=\"font-size:10px;\"> (New password 6-12 characters in length)<br />
<input class=\"form\" type=\"password\" disabled=\"disabled\" name=\"new_pass_c\" /><span style=\"font-size:10px;\"> (Confirm New password 6-12 characters in length)<br />
<br />
<input class=\"form\" type=\"text\" disabled=\"disabled\" name=\"current_email\" value=\"$email\" /><span style=\"font-size:10px;\"> (Current email)<br />
<input class=\"form\" type=\"text\" disabled=\"disabled\" name=\"new_email\" /><span style=\"font-size:10px;\"> (New email)<br />
<input class=\"form\" type=\"text\" disabled=\"disabled\" name=\"new_email_c\" /><span style=\"font-size:10px;\"> (Confirm New email)<br />
<br />
<label class=\"m\">Account Publicity:</label>ย <input type=\"radio\" disabled=\"disabled\" name=\"publicity\" value=\"private\" $checkprivate/> <span>Private</span><br />
<span style=\"margin-left:125px;\">ย <input type=\"radio\" disabled=\"disabled\" name=\"publicity\" value=\"public\" $checkpublic/> Public</span><br />
<br />
<label class=\"m\">Email List:</label>ย <input type=\"radio\" disabled=\"disabled\" name=\"newsletter\" value=\"yes\" $y_emails/> <span>Yes</span><br />
<span style=\"margin-left:125px;\">ย <input type=\"radio\" disabled=\"disabled\" name=\"newsletter\" value=\"no\" $n_emails/> No<br />
</form>
</div>
<br />";
Last edited:







