Remotive
19-04-2008, 09:42 PM
Hey everyone, well I am sorta stuck on changing this function, can anyone help me?
Well, here is this function I am talking about...
function add(obj)
{
var add = confirm("Do you wish to add \"" + obj.title + "\" to the your home?");
var grid = document.getElementById("grid");
var imgDump = document.getElementById("imgDump");
if (add)
{
var newId = "drag_" + getRandomId();
imgDump.innerHTML = '<img src="' + obj.src + '" id="' + newId + '"/>';
var newObj = document.getElementById(newId);
alert("\"" + obj.title + "\" has been successfully added to your home!");
grid.innerHTML +=
'<div title="' + obj.title + '" id="' + newId + '" onmousedown="dragStart(this.id);" onclick="getObjectInfo(this.id);"' +
'style="width:' + newObj.clientWidth + 'px; height:' + newObj.clientHeight + 'px; background-image:url(' + obj.src + '); top:0px; left:0px; z-index:1;"' +
'class="drag_object"></div>';
imgDump.innerHTML = "";
}
}
How would I make it so instead of the code being onclick="add(this)" it does something like onclick="add('bling_stars');"?
Bling stars being the image title and or name.
Thanks for any help given guys! http://www.techtuts.com/forums/style_emoticons/default/smile.gif
Well, here is this function I am talking about...
function add(obj)
{
var add = confirm("Do you wish to add \"" + obj.title + "\" to the your home?");
var grid = document.getElementById("grid");
var imgDump = document.getElementById("imgDump");
if (add)
{
var newId = "drag_" + getRandomId();
imgDump.innerHTML = '<img src="' + obj.src + '" id="' + newId + '"/>';
var newObj = document.getElementById(newId);
alert("\"" + obj.title + "\" has been successfully added to your home!");
grid.innerHTML +=
'<div title="' + obj.title + '" id="' + newId + '" onmousedown="dragStart(this.id);" onclick="getObjectInfo(this.id);"' +
'style="width:' + newObj.clientWidth + 'px; height:' + newObj.clientHeight + 'px; background-image:url(' + obj.src + '); top:0px; left:0px; z-index:1;"' +
'class="drag_object"></div>';
imgDump.innerHTML = "";
}
}
How would I make it so instead of the code being onclick="add(this)" it does something like onclick="add('bling_stars');"?
Bling stars being the image title and or name.
Thanks for any help given guys! http://www.techtuts.com/forums/style_emoticons/default/smile.gif