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:

HTML:
<input type="hidden" name="saveAsTemplate" value="0" />
 
TRIGGER:
<a href="" id="saveAsTemplate" class="toggleImage">Save as template</a>
 
JAVASCRIPT:
$('.toggleImage').each(function(){
    // shortcut to the current element
    var $this = $(this);
    // toggle the click handler
    $this.toggle(function(){
        // toggle the check image to the "on" state
        toggleImage($this,'save');
        toggleInput($this);
    },function(){
        // toggle the check image to the "off" state
        toggleImage($this,'save_faded');
        toggleInput($this);
    });
});
 
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);
}
 
Does anyone know why this isn't working right or, at some times, at all?
 
____________________________________
 
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