Anyone have input on this? This code runs, but it doesn't seem to want to
toggle the value of the form field at all. It changes it once, then
continues using the same value.

  _____  

From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Andy Matthews
Sent: Thursday, August 21, 2008 9:03 AM
To: [jQuery]
Subject: [jQuery] Best way to toggle a form field value


I'm storing a boolean in a hidden field, and I'd like to flip it's value
when someone clicks a link. Here's the function I've got currently:
 
function toggleInput($el) {
    // get the ID of the element being passed in
    var id = $el.attr('id');
    // get form element
    var $formEl = $('input[name=' + id + ']');
    // get the current value of the selected form field
    var value = $formEl.val();
    // set the new value 
    $formEl.val(!value);
    alert(value);
}
 
I seem to recall a way to invert the value in one line, but it's eluding me
at this time. Can someone help me out?
 
____________________________________
 
Andy Matthews
Senior ColdFusion Developer

Office:  615.627.9747
Fax:  615.467.6249
www.dealerskins.com <http://www.dealerskins.com/> 
 
Total customer satisfaction is my number 1 priority! If you are not
completely satisfied with the service I have provided, please let me know
right away so I can correct the problem, or notify my manager Aaron West at
[EMAIL PROTECTED]
 

<<2008 Email NADA.jpg>>

Reply via email to