chitra
07-20-2005, 06:03 AM
Thanks in adv.
I have seen both the links.But my requirement is I am having Select option which contains list of options like
<select>
<option>List1</option>
<option>List2</option>
<option>List3</option>
</select>
and 2 textboxes
<INPUT ID="Text1" value="">
<INPUT ID="Text2" value="">
Now I want to do coding such as I will select List1 and drag and drop(copy) it either in "Text1" or "Text2".
Can u tell me how to do that in Java script.I have got some code from internet for the same.But it is not working.Can u tell me what is missing in the following code:
<HEAD>
<SCRIPT>
/* ----------------------------------------------
fnSetInfo sets the data format in the first
parameter and provides the text to drop in second.
The second line copies text.
----------------------------------------------*/
function fnSetInfo() {
var txt1;
txt1=document.getElementbyID('oSource').innerText;
event.dataTransfer.setData("Text", txt1);
event.dataTransfer.effectAllowed = "copy";
}
/* ----------------------------------------------
fnGetInfo is called by the target
object in the ondrop event.
It cancels the default action and
sets the cursor to the system copy icon.
Then it specifies the data format to retrieve.
Last, it sets the value property of oTarget
object to the information from getData.
----------------------------------------------*/
function fnGetInfo() {
event.returnValue = false;
event.dataTransfer.dropEffect = "copy";
oTarget.value = event.dataTransfer.getData("Text");
}
/* ----------------------------------------------
fnCancelDefault
Cancels the default action in ondragenter
and ondragover so that the copy cursor is
displayed until the selection is dropped.
----------------------------------------------*/
function fnCancelDefault() {
event.returnValue = false;
event.dataTransfer.dropEffect = "copy";
}
function onmouseselect()
{
document.getElementbyID('oSource').innerText ;
}
</SCRIPT>
</HEAD>
<BODY>
<P>Drag and drop it onto the text box below. Text data will be pasted into the text box.</P>
<select id="oSource" ondragenter="fnSetInfo()" >
<option>List1</option>
<option>List2</option>
<option>List3</option>
</select>
<INPUT ID=oTarget VALUE="sdf"
ondragenter="fnCancelDefault()"
ondrop="fnGetInfo()"
ondragover="fnCancelDefault()">
</BODY>
I have seen both the links.But my requirement is I am having Select option which contains list of options like
<select>
<option>List1</option>
<option>List2</option>
<option>List3</option>
</select>
and 2 textboxes
<INPUT ID="Text1" value="">
<INPUT ID="Text2" value="">
Now I want to do coding such as I will select List1 and drag and drop(copy) it either in "Text1" or "Text2".
Can u tell me how to do that in Java script.I have got some code from internet for the same.But it is not working.Can u tell me what is missing in the following code:
<HEAD>
<SCRIPT>
/* ----------------------------------------------
fnSetInfo sets the data format in the first
parameter and provides the text to drop in second.
The second line copies text.
----------------------------------------------*/
function fnSetInfo() {
var txt1;
txt1=document.getElementbyID('oSource').innerText;
event.dataTransfer.setData("Text", txt1);
event.dataTransfer.effectAllowed = "copy";
}
/* ----------------------------------------------
fnGetInfo is called by the target
object in the ondrop event.
It cancels the default action and
sets the cursor to the system copy icon.
Then it specifies the data format to retrieve.
Last, it sets the value property of oTarget
object to the information from getData.
----------------------------------------------*/
function fnGetInfo() {
event.returnValue = false;
event.dataTransfer.dropEffect = "copy";
oTarget.value = event.dataTransfer.getData("Text");
}
/* ----------------------------------------------
fnCancelDefault
Cancels the default action in ondragenter
and ondragover so that the copy cursor is
displayed until the selection is dropped.
----------------------------------------------*/
function fnCancelDefault() {
event.returnValue = false;
event.dataTransfer.dropEffect = "copy";
}
function onmouseselect()
{
document.getElementbyID('oSource').innerText ;
}
</SCRIPT>
</HEAD>
<BODY>
<P>Drag and drop it onto the text box below. Text data will be pasted into the text box.</P>
<select id="oSource" ondragenter="fnSetInfo()" >
<option>List1</option>
<option>List2</option>
<option>List3</option>
</select>
<INPUT ID=oTarget VALUE="sdf"
ondragenter="fnCancelDefault()"
ondrop="fnGetInfo()"
ondragover="fnCancelDefault()">
</BODY>