javascript - Limit Number of Inputs onClick -
javascript - Limit Number of Inputs onClick -
i want allow 1 entry of text in textarea 1 time button clicked. if button clicked 2 or more times 1 entry should entered in textarea.
javascript:function inyectartexto(elemento,valor){ var elemento_dom=document.getelementsbyname(elemento)[0]; if(document.selection){ elemento_dom.focus(); sel=document.selection.createrange(); sel.text=valor; return; }if(elemento_dom.selectionstart||elemento_dom.selectionstart=="0"){ var t_start=elemento_dom.selectionstart; var t_end=elemento_dom.selectionend; var val_start=elemento_dom.value.substring(0,t_start); var val_end=elemento_dom.value.substring(t_end,elemento_dom.value.length); elemento_dom.value=val_start+valor+val_end; }else{ elemento_dom.value+=valor; } }
html: <a href="javascript:void(0);" onclick="inyectartexto('nametfield','hello world');" >say hello world text</a>
here issue if click link say hello world text
2 times text hello world
entered 2 times, want 1 set of hello world
should entered if link clicked how many times.
please help!
you can this:
var clicked = false; inyectartexto = function (elemento,valor){ var elemento_dom=document.getelementsbyname(elemento)[0]; if(!clicked){ elemento_dom.value += valor; clicked = true; } }
javascript html
Comments
Post a Comment