simonB2007
Programmer
I'm creating a textarea on-the-fly, and setting the onfocus event to :
function selTxt(){window.event.srcElement.select();}
However, the event is only firing if the user sets the cursor on the text within the textarea, and not the whole text area itself.
i.e. if the textarea is 20 chrs wide, and populated with 'abc' ... you've got to click on 'abc' for the event to fire, the other 17chrs of the textarea box is non-firing !
In fact, moving the cursor over the textarea, i get a 'pointer' on the box in general, and it only changes to the text editing cursor when it meets text.
When the textarea is empty, therefore, you can't get to enter new text unless you squeeze the cursor right into the lefthand edge ... not very friendly or easy !
Any help appreciated !!!
There are some overflow-Y css settings i am wondering about, but first stop i'm looking at, is whether i've created the elements correctly.
I've tried populating the textarea with "value=" and "innerHTML=" and "createTextNode('abc')" etc etc ... but as yet to no avail .... not much hair left !!!!
Here's the main code ... hope theres something obvious in there !!!
Thanks in advance !!
(ps. IE only for this one )
function makeCritEntry(inID, inDest, inTitle, inGroup){
var tbl
var tbd
var tr
var td
var ta
var sel
var dest
if(!document.getElementById(inDest)){return false}
this.fld = inID
this.group = inGroup;
this.id = this.fld + inGroup;
tbl = document.createElement("TABLE");
tbd = document.createElement("TBODY");
tr = document.createElement("TR");
td = document.createElement("TD");
tr2 = document.createElement("TR");
td2 = document.createElement("TD");
ta = document.createElement("TEXTAREA");
sel = document.createElement("SELECT");
tbl.style.setAttribute('cssText', 'padding:0px;margin:0px;border-collapse:collapse;',0);
sel.par = this;
sel.attachEvent('onkeyup',delEntry);
sel.id = "critcbo_" + this.id;
sel.setAttribute("style","z-index=101;");
sel.multiple = true;
ta.par = this;
ta.value = 'x';
ta.attachEvent('onkeypress',absEntry);
ta.attachEvent('ondblclick',showCritSel);
ta.attachEvent('onfocus',selTxt);
ta.id = "critTa_" + this.id;
ta.rows = "1"; ta.cols = "25";
// ...also tried ta.setAttribute("cols","20");
dest = document.getElementById(inDest);
dest.appendChild(tbl);
tbl.appendChild(tbd);
tbd.appendChild(tr);
tr.appendChild(td);
td.appendChild(ta);
tbd.appendChild(tr2);
tr2.appendChild(td2);
td2.appendChild(sel);
this.tbd = tbd;
this.ta = ta;
this.sel = sel;
}
function selTxt(){window.event.srcElement.select();}
However, the event is only firing if the user sets the cursor on the text within the textarea, and not the whole text area itself.
i.e. if the textarea is 20 chrs wide, and populated with 'abc' ... you've got to click on 'abc' for the event to fire, the other 17chrs of the textarea box is non-firing !
In fact, moving the cursor over the textarea, i get a 'pointer' on the box in general, and it only changes to the text editing cursor when it meets text.
When the textarea is empty, therefore, you can't get to enter new text unless you squeeze the cursor right into the lefthand edge ... not very friendly or easy !
Any help appreciated !!!
There are some overflow-Y css settings i am wondering about, but first stop i'm looking at, is whether i've created the elements correctly.
I've tried populating the textarea with "value=" and "innerHTML=" and "createTextNode('abc')" etc etc ... but as yet to no avail .... not much hair left !!!!
Here's the main code ... hope theres something obvious in there !!!
Thanks in advance !!
(ps. IE only for this one )
function makeCritEntry(inID, inDest, inTitle, inGroup){
var tbl
var tbd
var tr
var td
var ta
var sel
var dest
if(!document.getElementById(inDest)){return false}
this.fld = inID
this.group = inGroup;
this.id = this.fld + inGroup;
tbl = document.createElement("TABLE");
tbd = document.createElement("TBODY");
tr = document.createElement("TR");
td = document.createElement("TD");
tr2 = document.createElement("TR");
td2 = document.createElement("TD");
ta = document.createElement("TEXTAREA");
sel = document.createElement("SELECT");
tbl.style.setAttribute('cssText', 'padding:0px;margin:0px;border-collapse:collapse;',0);
sel.par = this;
sel.attachEvent('onkeyup',delEntry);
sel.id = "critcbo_" + this.id;
sel.setAttribute("style","z-index=101;");
sel.multiple = true;
ta.par = this;
ta.value = 'x';
ta.attachEvent('onkeypress',absEntry);
ta.attachEvent('ondblclick',showCritSel);
ta.attachEvent('onfocus',selTxt);
ta.id = "critTa_" + this.id;
ta.rows = "1"; ta.cols = "25";
// ...also tried ta.setAttribute("cols","20");
dest = document.getElementById(inDest);
dest.appendChild(tbl);
tbl.appendChild(tbd);
tbd.appendChild(tr);
tr.appendChild(td);
td.appendChild(ta);
tbd.appendChild(tr2);
tr2.appendChild(td2);
td2.appendChild(sel);
this.tbd = tbd;
this.ta = ta;
this.sel = sel;
}