|
#1
|
|||
|
|||
|
Hi Guys
Could someone give me a hand? I've got an asp form which will allow users to update their profile. At the bottom of the form there is a checkbox which depending on it's status will display some additional information for the user to fill out. The checkbox's initial value will be generated from their user record from the database. From here I then want to be able to hide/show the additional fields depending on both the checkbox checked status and the db variable. This would give 6 different combinations: db variable = 1, checkbox = NULL, additional fields = show db variable = 0, checkbox = NULL, additional fields = hide db variable = 1, checkbox = 1, additional fields = show db variable = 0, checkbox = 0, additional fields = hide db variable = 1, checkbox = 0, additional fields = hide db variable = 0, checkbox = 1, additional fields = show Any ideas on how to write this as a function? Thanks in advance Leigh |
|
#2
|
|||
|
|||
|
Maybe like this.
Code:
//obj is the HTML object
//db is a variable you pass
function additionalInfo(obj, db)
{
if( (obj.checked && db) || (obj.checked && !db) || (obj.checked == null && db))
{return true;}
else
{return false;}
}
In javascript using '==' means that 1==true and 0==false Code:
<input type="checkbox" onchange="additionalInfo(this,dbvalue)"> Last edited by Bob90; 05-25-2007 at 06:06 PM. |
|
#3
|
|||
|
|||
|
I'm somewhat confused as a checkbox cannot be "null": it's either checked (and successful) or not.
Is there some reason why this cannot be a two-part form?
__________________
Mike |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
|
|