Ask, Answer, Discover Knowledge
Login  |   Sign Up  |   Help

Discover > Answered Question

Query about createRange for textarea in javascripe
Asked by: tanishka from Pune, India
i shift value from list to rich textarea in specified position but it does not work for
document.selection .it produced undefined value so it can't go in loop
following is my function
my browser is Netscape and version>4

function shiftvalue(frm)
{

if(document.frm.columnName.value=="")
{
alert("Please Select Mail Parameter");
return false;
}
else
{
var tn=document.frm.dsrte_text;

var shiftValue = frm.columnName.options[frm.columnName.selectedInde
x].value;
alert(shiftValue);
//IE support
if (document.selection)
{

tn.focus();
sel = document.selection.createRange();
sel.text = shiftValue;
alert(sel.text)
}
//MOZILLA/NETSCAPE support
else if ((tn.selectionStart == 0) && (tn.selectionEnd == 0))
{
tn.value += shiftValue;
alert(tn.value);
}
else
{

var startPos = tn.selectionStart;
var endPos = tn.selectionEnd;
tn.value = tn.value.substring(0, startPos) + " " + shiftValue + " " + tn.value.substring(endPos, tn.value.length);

}
return false;
}
}


here i call that function
<input type="button" name="btnShift" value="<<" onclick="return shiftvalue(this.form);" >
Share: Digg del.icio.us  facebook  StumbleUpon Toolbar Stumble It! reddit
No Clarification Requests
 

Answer

User Rating:
Compliment Answer:    
Answer Compliments:   0  
O'Reilly Network -- Using JavaScript to Create a Powerful GUIcreateRange() implementation is currently broken in Mozilla, specifically in its inability to manipulate text in an input element or textarea element.
http://www.oreillynet.com/pub/...

thelist] Using Javascript to add tags to selected text in textarea[thelist...
Answer Date: 10:59pm 05/12/08
 
About This User
Username tanishka
Questions 1 Total (0 Withdrawn)
Question Rewards $0.00 Total / - Awarded
Questions Rating
User selects Best Answer 100% of the time
About This Question
Answered Question
Question Reward GroupAsk Reward
- -
Posted 05/06/08 Closed 05/13/08
User Views 422 Answers 1
Location Other
Tags career for site
URL
RSS
Related Questions