faqts : Computers : Programming : Languages : JavaScript : Event handling

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 12 people (58%) answered Yes
Recently 3 of 7 people (43%) answered Yes

Entry

how to pass selected text (non-form) to a form

Aug 2nd, 2001 05:41
zmx kiki, henrik marik,


function Test() 
	{
		if (document.all){//IE
			t = document.selection.createRange().text;
		}else{//Netscape (meme si le dblclick marche pas sous 
Netscape
			t = document.getSelection();
		}
		alert(t);
	}

With this you get the text of the selection under IE 4 + and Ne 4.x

Replace alert(t) by your document.form......value = t;

Good Luck