I have the following form :
<input name="linkColor" type="text" id="colorpickerField0" >
<input name="linkColor" type="text" id="colorpickerField1" >
<input name="linkColor" type="text" id="colorpickerField2" >
In my function below, how may I find out which text field has been invoked. For example, I want to set conditions in the onSubmit function where if #colorpickerField0 then do blah blah, and if #colorpickerField1 THEN do blah blah blah etc etc. Any help will be greatly appreciated. Thanks
$('#colorpickerField0, #colorpickerField1, #colorpickerField2').ColorPicker({
onSubmit: function(hsb, hex, rgb, el) {
alert($(this));
// do this if #Field0
// statements
// do this if #Field1
// statements
// do this if #Field2
// statemets
$(el).val(hex);
$(el).ColorPickerHide();
},
onBeforeShow: function () {
$(this).ColorPickerSetColor(this.value);
}
})
.bind('keyup', function(){
$(this).ColorPickerSetColor(this.value);
});
I'm using http://www.eyecon.ro/colorpicker/
If I do alert($(this).attr('id')); I get undefined, so I still can't tell which one was used.
if ($(el).attr('id') == 'colorpickerField0') { ...
}