|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
testing for field disabled = true or false
I tryed to make a snippet that would allow to me to set a text field to disabled if a checkbox was clicked,...and re-enable it if the same checkbox was clicked again. am I on the right track here?
Code:
<script type="text/javascript" language="javascript">
<!--
function checkFieldStatus( theForm, theElement )
{
if( theForm.theElement.disabled = true )
{
setFieldEnabled( theForm, theElement );
}
if( theForm.theElement.disabled = false )
{
setFieldDisabled( theForm, theElement );
}
}
function setFieldDisabled( theForm, theElement )
{
theForm.theElement.disabled = true;
theForm.theElement.onfocus = theForm.theElement.blur;
}
function setFieldEnabled( theForm, theElement )
{
theForm.theElement.disabled = false;
theForm.theElement.onfocus = null;
}
// -->
</script>
Code:
onclick="checkFieldStatus( document.myForm, the_field_to_check )"
__________________
-- Jason |
|
#2
|
|||
|
|||
|
This being a lot simpler might just help you out:
PHP Code:
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
|
#3
|
|||
|
|||
|
very very nice..... me likes
![]() |
|
#4
|
||||
|
||||
|
Nice indeed.
Also, in case this was a mistake and not a typo, the conditions in your if statements used assignment operators rather than logical operators. I think this probably always evaluates to true (unless you have something like division by 0 on the right side of the operator). Make sure you use == rather than = if you're testing a condition. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > testing for field disabled = true or false |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|