Okay, having quite a few problems here. I'm working from a new version..
Code: Select all
function createAlert(id_num, crs_cde)
{
if(document.getElementById('subDiv'))
{
document.body.removeChild('subDiv');
}
subDiv = document.createElement("div");
subDiv.className='alertPopup';
subDiv.id='subDiv';
document.body.appendChild(subDiv);
document.getElementById('subDiv').style.left = event.clientX;
document.getElementById('SubDiv').style.top = event.clientY;
content = "Some text goes here.<br>";
content += "<input type='checkbox' id='alert_1' value='1'>option1<br>";
content += "<input type='checkbox' id='alert_2' value='1'>option2<br>";
content += "<input type='checkbox' id='alert_3' value='1'>option3<br>";
content += "<input type='checkbox' id='alert_4' value='1'>option4<br>";
content += "<input type='checkbox' id='alert_5' value='1'>option5<br>";
content += "<input type='checkbox' id='alert_6' value='1'>option6<br>";
content += "<center><input class='input_button' type='button' value='Cancel' onclick='document.body.removeChild(subDiv);'> ";
content += "<input class='input_button' type='button' value='Alert' onclick='alertSend();'><\/center>";
document.getElementById('subDiv').innerHTML = content;
document.getElementById('subDiv').style.display = '';
}
First, insertbefore has to have a second item - the target to insert the new item in front of.
Second, createelement was all kinds of wrong. You cant set id's and classes on created elements that way. More like..
Code: Select all
subDiv = document.createElement("div");
subDiv.className='alertPopup';
subDiv.id='subDiv';
But to do that correctly, you really need to appendChild that onto something (or else its just floating, in undefined space).
The event call is the really confusing part. You are asking for an event from a createElement - which isnt an event the user did. Worse, you are asking for the clientX/Y for that subdiv, NOT for where they clicked.
No offense, but the code looks like a badly cobbled together collection of different scripts, that dont work together well. I'd help more, but sadly, I dont know enough about JS to do "what you meant to do".