javascript - Autofill Textbox using buttons -
i have php application i'm working on. here's i'm trying do:
i have search box (textbox) , several buttons. on clicking each button, want fill search box predefined string. clicking button erase what's in search box , replace value pre-defined string. , button clear textbox well.
example:
button 1 on click -> textbox value = button1 button 2 on click -> textbox value = button2 (old value replaced) can guide me js code this? thanks!
apply 'button' class every button , unique id each button.
$(".button").click(function(){ var id = this.id; $('#searchtextid').val($('#'+id).attr('value')); });
Comments
Post a Comment