Jump to content

cleary1981

Members
  • Posts

    210
  • Joined

  • Last visited

Everything posted by cleary1981

  1. Ive heard of it. Does that mean much reworking or can I use it just in this part?
  2. Thanks I was just looking at how I could shorten that code. Have you any ideas why all my objects are not updating. Is there a way I could make one write to the database instead of doing each one individually?
  3. i built a 2d game in java once using a java applet. I didnt use xml in it though. try googling GUI's using applets.
  4. ok. After more testing it seems that which objects get updated is completely random which makes me think that the system is busy when it loops through on some occasions. Does that sound possible?
  5. Ok! I have just noticed it is only the 1st object that will not update. The others do
  6. Yeah I have tried that already and it didnt make any difference. Any other ideas?
  7. I want to send some details to my database about a number of objects. Below is the code I have written but the problem I am having is that it only actually updates the details of the last object. Where am I going wrong? function render () { var yReturnValue = -5;var xReturnValue = -10; var arr = new Array(); arr = document.getElementsByTagName("div"); //make array of all divs with id = newObject // alert("Total Number of DIV Elements Found: " + document.documentElement.getElementsByTagName("div").length); for(var i=0; i < arr.length; i++) { //check innerHTML against obj_name result = document.documentElement.getElementsByTagName("div").item(i).innerHTML; yelementid=document.documentElement.getElementsByTagName("div").item(i); while( yelementid != null ){ yReturnValue += yelementid.offsetTop; yelementid = yelementid.offsetParent; } xelementid=document.documentElement.getElementsByTagName("div").item(i); while( xelementid != null ){ xReturnValue += xelementid.offsetLeft; xelementid = xelementid.offsetParent; } // alert("Name: " + result + " x: " + xReturnValue + " y: " + yReturnValue); } var url = "render.php?result=" + escape(result) + "&xReturnValue=" + escape(xReturnValue) + "&yReturnValue=" + escape(yReturnValue); url = url + "&dummy=" + new Date().getTime(); request.open("GET", url, true); request.send(null); }
  8. Hi, I can't find any good examples of this. What I want to do is setup an array for all the children of a given element. In my case the root element should be 'canvas', and the number of child nodes and their attributes will vary. Help very much appreciated or a link to a decent tutorial. Thanks
  9. I seen that exmaple myself but dont know how to apply it to my code.
  10. take a look at the third demo on this page I think its close to what you want to do http://www.webreference.com/programming/javascript/mk/column2/3.html
  11. Hi, I have a function that creates an object and now im working on the function to delete objects. I have most of the code written but cant figure out how to actually delete the object. Should I use removechild or what. Take a look at my code. I have included the create object function as it might be some help. function createObject() { var g_model = document.getElementById("model").value; g_objName = document.getElementById("objName").value; g_projID = document.getElementById("projID").value; var url = "create_object.php?g_model=" + escape(g_model) + "&g_objName=" + escape(g_objName) + "&g_projID=" + escape(g_projID); request.open("GET", url, true); request.onreadystatechange = showObject; request.send(null); } function showObject (){ document.getElementById('objName').value = ""; 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"); var 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); } } 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); var arr = new Array(); arr = document.getElementsByTagName("div"); //make array of all divs with id = newObject // alert("Total Number of HTML Elements Found: " + document.documentElement.getElementsByTagName("div").length); for(var i=0; i < arr.length; i++) { //check innerHTML against obj_name result = document.documentElement.getElementsByTagName("div").item(i).innerHTML; if (result == obj_name) { //delete current object } } }
  12. 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.
  13. have you tried http://www.webreference.com/programming/javascript/
  14. If you work your way through w3c tutorials you will get the basics. I find it quite handy to refer to if I can't remeber syntax http://www.w3schools.com/JS/default.asp Also you can have a look at some frameworks like http://script.aculo.us/ Using these makes programming much easier. Hope this helps
  15. sorry.. just back there. I got it thanks for your help
  16. ok. I have placed the code in the second page and used the below line to show the output which is not showing anything <span>show here<?php $proj_id_edit; ?></span>
  17. I have placed it in first. Havnt recieved any errors. How do I check it has passed to second page?
  18. does this go into the second page?
  19. Hi I have two pages where I want to pass a value from one page to the next. I want to pass "proj_id_edit".Heres my first page. <?php if ($_COOKIE["auth"] == "1") { } else { //redirect back to login form if not authorised header ("Location: loginform.html"); exit; } ?> <html> <head> <title>TES - Business Developement</title> <link rel="icon" href="/favicon.ico" type="image/x-icon" /> <link rel="stylesheet" type="text/css" href="style.css" /> <style type="text/css"> </style> <script language="javascript" src="list_companies.php"></script> <script type="text/javascript" src="text-utils.js"> </script> <script type="text/javascript" src="request.js"> </script> <script type="text/javascript"> var p_id; window.onload = function() { fillCompany(); } function get_Company() { fillProject(); var comp = document.getElementById("Company").value; var url = "lookupAccNo.php?comp=" + escape(comp); request.open("GET", url, true); request.onreadystatechange = updateAccNo; request.send(null); } function updateAccNo() { if (request.readyState ==4) { var accountnumber = request.responseText; var x = document.getElementById("acc_no"); replaceText(x, accountnumber); } } function get_project() { var proj = document.getElementById("project").value; var url = "lookupProjId.php?proj=" + escape(proj); url = url + "&dummy=" + new Date().getTime(); request.open("GET", url, true); request.onreadystatechange = updateProj; request.send(null); } function updateProj() { if (request.readyState == 4) { var returned = request.responseText; var splitResult = returned.split("%"); var r_proj_id = splitResult[0]; var r_projName = splitResult[1]; var r_form = splitResult[2]; var r_access = splitResult[3]; var r_cable = splitResult[4]; var r_ip = splitResult[5]; var r_fault = splitResult[6]; var r_comp = splitResult[7]; var r_pman = splitResult[8]; var r_deadline = splitResult[9]; document.company1.proj_id_edit.value = r_proj_id; document.company1.projName_edit.value = r_projName; document.company1.comp_edit.value = r_comp; document.company1.access_edit.value = r_access; document.company1.cable_edit.value = r_cable; document.company1.ip_edit.value = r_ip; document.company1.fault_edit.value = r_fault; document.company1.iform_edit.value = r_form; document.company1.pman_edit.value = r_pman; document.company1.deadline_edit.value = r_deadline; } } function updateProjectDetails() { var uproj_id = document.getElementById("proj_id_edit").value; var uaccess = document.getElementById("access_edit").value; var ucable = document.getElementById("cable_edit").value; var uip = document.getElementById("ip_edit").value; var ufault = document.getElementById("fault_edit").value; var uform = document.getElementById("iform_edit").value; var upman = document.getElementById("pman_edit").value; var udl = document.getElementById("deadline_edit").value; var url = "updateProjectDetails.php?uproj_id=" + escape(uproj_id) + "&uaccess=" + escape(uaccess) + "&ucable=" + escape(ucable) + "&uip=" + escape(uip) + "&ufault=" + escape(ufault) + "&uform=" + escape(uform) + "&upman=" + escape(upman) + "&udl=" + escape(udl); url = url + "&dummy=" + new Date().getTime(); request.open("GET", url, true); request.onreadystatechange = showConfirmation; request.send(null); } function showConfirmation () { if (request.readyState == 4) { var xx = document.getElementById("xx"); ss = document.createTextNode("Update complete"); xx.appendChild(ss); var t=setTimeout("xx.removeChild(ss)",2000); //display message for 2seconds then removes it } } function openDesignMode() { window.open('designmode.php', 'Design View', 'statusbar=yes'); } </script> </head> <body> <form name="company1" action="updateProjectDetails.php" method="POST"> <fieldset> <legend>1. Select Company (or add company to database then press F5 to refresh list)</legend> <table border=0 width=100%><tr><td width=45%><div><label for="Company" id="label1">Company Name</label> <SELECT id="Company" NAME="Company" onChange="get_Company()"> <Option value="">Existing Company</option> </SELECT></div></td> <td width=45%><div><label for="acc_no" id="label2">Account Number</label> <span id="acc_no"> </span></div></td> <td><input type = "button" value = "newCompany" id="comp_button" onClick = "window.open('newcompany.php', 'NewCompany', 'width=400, height=400 statusbar=yes')"> </td></tr></table> </fieldset> <fieldset> <legend>2. Select an existing project or create a new project</legend> <table border=0 width=100%><tr><td width=45%><div><label for="project">Project Name</label> <SELECT id="project" NAME="project" onChange="get_project();"> <Option value="">Existing Project</option> </SELECT></div></td> <td width=45%><div> <span id="proj_id1"> </span></div></td> <td><input type = "button" value = "New Project" onClick = "window.open('newproject.php', 'NewProject', 'width=400, height=400 statusbar=1, status=yes')"> </td></tr></table> </fieldset> <fieldset> <legend>3. Update project details (if required)</legend> <table width=100% border=0> <tr> <td><label for="proj_id_edit">Project ID</label> <input type = "text" value = "" disabled name = "proj_id_edit" id = "proj_id_edit" onChange="setProject"></td> <td><label for="projName_edit">Project Name</label> <input type = "text" value = "" disabled name = "projName_edit" id = "projName_edit"></td></tr> <tr><td><label for="comp_edit">Company Name</label> <input type = "text" value = "" disabled name = "comp_edit" id = "comp_edit"></td> <td><label for="access_edit">Access</label> <input type = "text" value = "" name = "access_edit" id = "access_edit"></td></tr> <tr><td><label for="cable_edit">Cable Entry</label> <input type = "text" value = "" name = "cable_edit" id = "cable_edit"></td> <td><label for="ip_edit">IP Rating</label> <input type = "text" value = "" name = "ip_edit" id = "ip_edit"></td></tr> <tr><td><label for="fault_edit">Fault Rating</label> <input type = "text" value = "" name = "fault_edit" id = "fault_edit"><span>KW/sec</span></td> <td><label for="iform_edit">Form</label> <input type = "text" value = "" name = "iform_edit" id = "iform_edit"></td></tr> <tr><td><label for="pman_edit">Project Manager</label> <input type = "text" value = "" name = "pman_edit" id = "pman_edit"></td> <td><label for="deadline_edit">Tender Deadline</label> <input type = "text" value = "" name = "deadline_edit" id = "deadline_edit"></td> </tr> <tr><td><input type="button" value="Update" name="update" onClick="updateProjectDetails()"> <div id="xx"></div></td></tr></table> </fieldset> <fieldset> <legend>4. Proceed to Design Mode</legend> <input type="button" value="Design Mode" onClick = "window.open('designmode.php?p_id = {document.getElementById("proj_id_edit").value}', '', 'width=1280, height=700, resizable=yes, statusbar=yes')"> </fieldset> </form> </body> </html> Heres the second <?php if ($_COOKIE["auth"] == "1") { } else { //redirect back to login form if not authorised header ("Location: loginform.html"); exit; } ?>
  20. what do you mean by this? Where are you talking about?
  21. i have tried it using url but whats wrong with my code <table width=100% border=0> <tr> <td><label for="proj_id_edit">Project ID</label> <input type = "text" value = "" disabled name = "proj_id_edit" id = "proj_id_edit" onChange="setProject"></td> <td><label for="projName_edit">Project Name</label> <input type = "text" value = "" disabled name = "projName_edit" id = "projName_edit"></td></tr> <tr><td><label for="comp_edit">Company Name</label> <input type = "text" value = "" disabled name = "comp_edit" id = "comp_edit"></td> <td><label for="access_edit">Access</label> <input type = "text" value = "" name = "access_edit" id = "access_edit"></td></tr> <tr><td><label for="cable_edit">Cable Entry</label> <input type = "text" value = "" name = "cable_edit" id = "cable_edit"></td> <td><label for="ip_edit">IP Rating</label> <input type = "text" value = "" name = "ip_edit" id = "ip_edit"></td></tr> <tr><td><label for="fault_edit">Fault Rating</label> <input type = "text" value = "" name = "fault_edit" id = "fault_edit"><span>KW/sec</span></td> <td><label for="iform_edit">Form</label> <input type = "text" value = "" name = "iform_edit" id = "iform_edit"></td></tr> <tr><td><label for="pman_edit">Project Manager</label> <input type = "text" value = "" name = "pman_edit" id = "pman_edit"></td> <td><label for="deadline_edit">Tender Deadline</label> <input type = "text" value = "" name = "deadline_edit" id = "deadline_edit"></td> </tr> <tr><td><input type="button" value="Update" name="update" onClick="updateProjectDetails()"> <div id="xx"></div></td></tr></table> </fieldset> <fieldset> <legend>4. Proceed to Design Mode</legend> <input type="button" value="Design Mode" onClick = "window.open('designmode.php?p_id = {document.getElementById("proj_id_edit").value}', '', 'width=1280, height=700, resizable=yes, statusbar=yes')"> </fieldset>
  22. I need to set a php variable to the same value as this line of php so I can pass it to the next page. How do I go about it? <input type = "text" value = "" disabled name = "proj_id_edit" id = "proj_id_edit" onChange="setProject"></td> $p_id = proj_id_edit.value
  23. dont suppose you want to take a stab at what I am trying to do here? Im trying to get the x and y postion of each object with an id of newObject and insert the details into my db
  24. yeah worked it out. Just changed to var ww = document.getElementById("newObject").id;
×
×
  • 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.