Joseph wrote:
Is is possible and how would I implemente dragging and dropping a value in a textbox so that it would clear the existing value in
the textbox, if it has one already?
IE (5 and later) on Win has support for drag/drop handlers, here is a
simple example tested with IE 6 where any text dropped on the text input
replaces the existing value of the control:
<html lang="en">
<head>
<title>custom drop on text control</title>
<script type="text/javascript">
function dropHandler (evt) {
evt = evt || window.event;
if (evt.srcElement && evt.srcElement.type && evt.dataTransfer &&
(evt.srcElement.type == 'text' || evt.srcElement.type == 'textarea'))
{
evt.srcElement.value = evt.dataTransfer.getData('Text');
return false;
}
}
function setDropHandler (elementId, dropHandler) {
var element;
if (document.getElementById && (element =
document.getElementById(elementId))) {
element.ondrop = dropHandler;
}
}
</script>
</head>
<body>
<h1>custom drop</h1>
<p>Select text here and drag and drop on text control.</p>
<div>
<input type="text" id="input1" value="Kibology">
</div>
<script type="text/javascript">
setDropHandler('input1', dropHandler);
</script>
</body>
</html>
--
Martin Honnen
http://JavaScript.FAQTs.com/