Javascript: Event.value

  • Follow


I have some checkboxes and I want to put the export value of the
checkbox into a text field, which will get picked up in a function. 
In the checkbox MouseUp action, I tried the following:

if (event.value != "Off")
  {
  this.getField("textfield").value = event.value;
  }

But "textfield" winds up with a blank value, unless I do this:

if (this.getField("checkbox").value != "Off")
  {
  this.getField("textfield").value = this.getField("checkbox").value;
  }

Why doesn't event.value work here?  Thanks for your time.

David
0
Reply david 9/19/2003 1:10:49 PM

Well David the answer to your question is staring straight in the face. Read you own message again.

You start with an if statement to evaluate whether event.value equals "On" or "Off" (so far so 
good), then in the very next line you attempt to use the event.value as the export value (sorry, 
wrong approach). Do you see the contradiction in your code? (-:

In the case of a check box, the event value and the export value are two different things. The event 
value is a boolean, and the export value is text data.

However in the case of a text field the event value is the actual text data in the field.

You're certainly not the first person to make this mistake.
Your revised code is the correct way to go.

Bryan



David wrote:
> I have some checkboxes and I want to put the export value of the
> checkbox into a text field, which will get picked up in a function. 
> In the checkbox MouseUp action, I tried the following:
> 
> if (event.value != "Off")
>   {
>   this.getField("textfield").value = event.value;
>   }
> 
> But "textfield" winds up with a blank value, unless I do this:
> 
> if (this.getField("checkbox").value != "Off")
>   {
>   this.getField("textfield").value = this.getField("checkbox").value;
>   }
> 
> Why doesn't event.value work here?  Thanks for your time.
> 
> David

0
Reply ThePDFExpert 9/21/2003 3:33:46 PM


1 Replies
871 Views

(page loaded in 0.068 seconds)

Similiar Articles:













7/23/2012 4:00:32 PM


Reply: