troubleshooting Question

Enabling and disabling text input onclicking a radio button

Avatar of padmasambhava
padmasambhava asked on
JavaScript
7 Comments1 Solution287 ViewsLast Modified:
Hi Experts,

I'm writing an admin page for a site and this particular bit allows an admin to set the text that will be displayed when the system is down.  It comes in two flavors, one for taking it down immediately and the other to give a warning and then take it down.  The default message is to take it down immediately.

I've got two radio buttons to allow selecting one or the other and some javascript that should enable and disablethe textarea message text.  When the page loads it defaults to the default message but clicking on the other radio button doesn't seem to run the javascript to enable the other textarea.

Thanks for any insight.
Peter



<fieldset><legend>Take the site up or down</legend><hr>
<form method="post" action="admin_site_availability.asp" name="site_availability_form">
<table width="100%">
  <tr>
    <td width="10%"><input type="radio" name="rbMsgSource" value="useDefault" checked onclick="enableDefault()"></td>
    <td width="90%">Use this default message when you are taking the system down immediately.</td>
  </tr>
  <tr>
    <td></td>
    <td><textarea name="txtDefaultMessage" rows="5" cols="35"><%= msgAvailabilityDefault %></textarea></td>
  </tr>
</table><hr>

<table width="100%"
  <tr>
      <td width="10%"><input type="radio" name="rbMsgSource" value="useCustom" onclick="enableCustom()"></td>
      <td width="90%">Use this warning message and announcement message when you want to schedule a maintenance window.  Remember you must still take the system down at the proper time, and also bring it back up.</td>
  </tr>
  <tr>
      <td width="10%"></td>
      <td><textarea name="txtCustomWarning" rows="5" cols="35" disabled="true"><%= msgAvailabilityWarning %></textarea></td>
  </tr>
  <tr>
      <td width="10%"></td>
      <td><textarea name="txtCustomMessage" rows="5" cols="35" disabled="true"><%= msgAvailabilityCustom %></textarea></td>
  </tr>
  <tr>
    <td><input type="submit" value="Submit"></td>
  </tr>
</table>
</form>
</fieldset>

<script type="text/javascript">
function enableDefault() {
  document.site_availability_form.txtDefaultMessage.disabled=false;
  document.site_availability_form.txtCustomWarning.disabled=true;
  document.site_availability_form.txtCustomMessage.disabled=true;
  }
function enableCustom() {
  document.site_availability_form.txtDefaulMessage.disabled=true;
  document.site_availability_form.txtCustomWarning.disabled=false;
  document.site_availability_form.txtCustomMessage.disabled=false;
  }
</script>
ASKER CERTIFIED SOLUTION
fre77

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 7 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 7 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004