Disable button and change button value at radio 
Author Message
 Disable button and change button value at radio

In an ASP page, I want to disable some buttons or change the button value
when a radio box is selected.
I tried to use _onclick and _onchange function.  But neither worked.  (see
code below)
What is wrong?  Should I use another function to catch the event?  Or
something else?
Thanks for your advice  -- Jason

----------------------------------------------------------------------------
---------
Sub rdoMode_onclick        ' I also use _onchange function.  Didn't work,
either.
If rdoMode.value=add Then
Set document.FORM1.btnAction.disabled=false
End If
If rdoMode.value=modify Then
Set document.FORM1.btnAction.value=Modify
End If
If rdoMode.value=delete Then
Set document.FORM1.btnAction.value=Delete
End If
End Sub



Thu, 22 Apr 2004 12:41:00 GMT  
 Disable button and change button value at radio
You can't assign event handers with the "Sub objName_event" method to
multiple controls with the same name. In this case, objName is a collection
and the controls are objName(0...n). If you want to use the "Sub
objName_event" with radio buttons, you have to give each one a unique id
(rdoModeAdd, rdoModeModify, rdoModeDelete) and give each one its own
handler. On the plus side, you won't have to test the value, because you'll
know which radio button was clicked by which hander is called.

You can't determine a radio button group's value with rdoName.value. You
have to walk the collection, looking for item whose clicked attribute is
True, and examine its value.

String values are delimited with quotes!

If you want to toggle control's attributes with a radio button, be sure to
set it in each of the radio buttons' handler. Otherwise, the user could
click the "Add" radio button to enable the btnAction button, and then click
one of the other radio buttons and the btnAction button would still be
enabled.

Sub rdoModeAdd_OnClick
 With document.FORM1.btnAction
  .value="Add"
  .disabled=False
 End With
End Sub
Sub rdoModeModify_OnClick
 With document.FORM1.btnAction
  .value="Modify"
  .disabled=True
 End With
End Sub
Sub rdoModeDelete_OnClick
 With document.FORM1.btnAction
  .value="Delete"
  .disabled=True
 End With
End Sub

--
The palest ink is better than the best memory. -Chinese proverb

=-=-=
Steve
-=-=-


Quote:
> In an ASP page, I want to disable some buttons or change the button value
> when a radio box is selected.
> I tried to use _onclick and _onchange function.  But neither worked.  (see
> code below)
> What is wrong?  Should I use another function to catch the event?  Or
> something else?
> Thanks for your advice  -- Jason

> --------------------------------------------------------------------------
--
> ---------
> Sub rdoMode_onclick        ' I also use _onchange function.  Didn't work,
> either.
> If rdoMode.value=add Then
> Set document.FORM1.btnAction.disabled=false
> End If
> If rdoMode.value=modify Then
> Set document.FORM1.btnAction.value=Modify
> End If
> If rdoMode.value=delete Then
> Set document.FORM1.btnAction.value=Delete
> End If
> End Sub



Thu, 22 Apr 2004 20:31:29 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to read directories into TTreeView

2. Creating a ODBC connection

3. disable close button without disabling make small button

4. Create radio button set using Push Buttons?

5. Disabling textbox by radio button selection

6. Disable mutual exclusive radio buttons ?

7. Radio Button Disable/Enable

8. Selecting/Disabling radio buttons

9. SQL Question

10. AGP in TurboPascal

11. tpdezip.zip Turbo Pascal dezip code by Byrne, crashprone?

12. Looking for DB-Grdi-Component

 

 
Powered by phpBB® Forum Software