weirddemon
05-12-2008, 03:40 AM
I was recently able to include a javascript to make images draggable within a drop down menu. I need to duplicate the image while still being able to drag it.
When dragging the image, after changing the drop down menu selection, the image just changes while being in it's previous position. The part of the code that I've included the "drag" function is:
</td>
</tr>
<tr>
<td width="100%"><p align="center"><img src="images/Serpentine_1.jpg" name="pictures" width="99" height="100" id="serpentine1" style="position:relative;"></td>
</tr>
</table>
There is a piece of the code that tells us what text you see when you look in the drop down menu and what image that text applies to
<tr>
<td width="100%"><form name="mygallery"><p>
<select name="picture" size="1" onChange="showimage()">
<option selected value="images/Serpentine_1.jpg">Serpentine</option>
<option value="images/4'-Section.gif">4' Section</option>
<option value="example">Example</option>
</select>
</p>
</form>
</td>
</tr>
When I try to include the drag function into the images without having the function into the previous code, it makes it undraggable.
Here is the entire code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script language="javascript">
function showimage()
{
if (!document.images)
return
document.images.pictures.src=
document.mygallery.picture.options[document.mygallery.picture.selectedIndex].value
}
//-->
</script>
<title> </title>
<style type="text/css">body {
background-image: url(images/8.5x11.gif);
background-repeat: no-repeat;
background-position:center;
}
</style>
<script type="text/javascript" src="scripts/dom-drag.js"></script>
<script type="text/javascript">
window.onload = function(){
Drag.init(document.getElementById("serpentine"));
Drag.init(document.getElementById("midsection"));
Drag.init(document.getElementById("serpentine1"));
Drag.init(document.getElementById("4foot"));
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<body>
<img id="serpentine" src="images/Serpentine_1.jpg" style="position: relative" />
<img id="midsection" src="images/4'-Section--Mid.gif" style="position: relative" />
<img id="example" src="pattern.gif" style="position: relative" />
<img id="example4" src="me.gif" style="position: relative" />
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><form name="mygallery"><p>
<select name="picture" size="1" onChange="showimage()">
<option selected value="images/Serpentine_1.jpg">Serpentine</option>
<option value="images/4'-Section.gif" id="4foot">4' Section</option>
<option value="Example">Example</option>
</select>
</p>
</form>
</td>
</tr>
<tr>
<td width="100%"><p align="center"><img src="images/Serpentine_1.jpg" name="pictures" width="99" height="100" id="serpentine1" style="position:relative;">
</td>
</tr>
</table>
</body>
</html>
I've included the zip file if you want to see exactly what it is I am working with.
Thanks
When dragging the image, after changing the drop down menu selection, the image just changes while being in it's previous position. The part of the code that I've included the "drag" function is:
</td>
</tr>
<tr>
<td width="100%"><p align="center"><img src="images/Serpentine_1.jpg" name="pictures" width="99" height="100" id="serpentine1" style="position:relative;"></td>
</tr>
</table>
There is a piece of the code that tells us what text you see when you look in the drop down menu and what image that text applies to
<tr>
<td width="100%"><form name="mygallery"><p>
<select name="picture" size="1" onChange="showimage()">
<option selected value="images/Serpentine_1.jpg">Serpentine</option>
<option value="images/4'-Section.gif">4' Section</option>
<option value="example">Example</option>
</select>
</p>
</form>
</td>
</tr>
When I try to include the drag function into the images without having the function into the previous code, it makes it undraggable.
Here is the entire code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script language="javascript">
function showimage()
{
if (!document.images)
return
document.images.pictures.src=
document.mygallery.picture.options[document.mygallery.picture.selectedIndex].value
}
//-->
</script>
<title> </title>
<style type="text/css">body {
background-image: url(images/8.5x11.gif);
background-repeat: no-repeat;
background-position:center;
}
</style>
<script type="text/javascript" src="scripts/dom-drag.js"></script>
<script type="text/javascript">
window.onload = function(){
Drag.init(document.getElementById("serpentine"));
Drag.init(document.getElementById("midsection"));
Drag.init(document.getElementById("serpentine1"));
Drag.init(document.getElementById("4foot"));
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<body>
<img id="serpentine" src="images/Serpentine_1.jpg" style="position: relative" />
<img id="midsection" src="images/4'-Section--Mid.gif" style="position: relative" />
<img id="example" src="pattern.gif" style="position: relative" />
<img id="example4" src="me.gif" style="position: relative" />
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><form name="mygallery"><p>
<select name="picture" size="1" onChange="showimage()">
<option selected value="images/Serpentine_1.jpg">Serpentine</option>
<option value="images/4'-Section.gif" id="4foot">4' Section</option>
<option value="Example">Example</option>
</select>
</p>
</form>
</td>
</tr>
<tr>
<td width="100%"><p align="center"><img src="images/Serpentine_1.jpg" name="pictures" width="99" height="100" id="serpentine1" style="position:relative;">
</td>
</tr>
</table>
</body>
</html>
I've included the zip file if you want to see exactly what it is I am working with.
Thanks