Jump to content

[SOLVED] delete object


cleary1981

Recommended Posts

Hi I'm having a problem trying to delete an object in javascript. Heres the code I used to create it.

 

function showObject (){
if (request.readyState == 4) {
var returned = request.responseText;
var splitResult = returned.split(" ");
var h = splitResult[0];
var w = splitResult[1];	// the dimensions must be set to a scale as they are to big for the screen. 25px represents 100mm
h = h/5;
w = w/5;

cv = document.getElementById("canvas");
newObject = document.createElement('div');
newObject.Class = g_objName;
newObject.id = "newObject";
newObject.innerHTML = g_objName;
newObject.alt = g_objName;
newObject.style.height = h;
newObject.style.width = w;
newObject.onmousedown=function(){grab(this);}	
cv.appendChild(newObject);
}
}

 

heres what I have so far on the delete function

 

function obj_delete() {
var obj_name = document.getElementById("object").value;
var proj_id = document.getElementById("projID").value;
var url = "deleteObject.php?obj_name=" + escape(obj_name) + "&proj_id=" + escape(proj_id);
request.open("GET", url, true);
request.send(null);
delete canvas.Child;
}

 

As you can see from my code I have deleted the object in my db ok but I need to be able to delete the object on the webpage. newObject where its innerHTML = var obj_name in the delete function. Any help much appreciated.

Link to comment
Share on other sites

The way I see it you are trying to remove an element with an id of "object" and the element you created was "newObject." Anyway, since you used appendChild() to put the object somewhere, you just have to use removeChild() to take it away.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.