Roshan Wijesena
Roshan Wijesena

Reputation: 3136

text assign to textbox onclick hyperlink

I have problem on jquery onclick. when onclick happen on a link text box value should fill with the some hard coded text.

ex

  $('#linkBase').click(function() {

         $('#txtFormula').val("txnword");

    });

problem is I want to repeat the "txtword" on the text box when I click on the link as "txtwordtxtwordtxtwordtxtwordtxtword" but currently I'm getting only once when click the link.

Upvotes: 3

Views: 376

Answers (3)

cvsguimaraes
cvsguimaraes

Reputation: 13230

For those that doesn't use jQuery for simple things like this:

document.querySelector('#linkBase').onclick = function()
{
    document.querySelector('#txtFormula').value += "txnword";
};

Upvotes: 0

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

var formula = $('#txtFormula');
formula.val(formula.val() + "txnword");

Upvotes: 4

Timbo
Timbo

Reputation: 4533

Try this:

 $('#linkBase').click(function() {
               $('#txtFormula').val($('#txtFormula').val() + "txnword");                 
});

Upvotes: 6

Related Questions