P
Petesman
I am trying to make a prompt that will ask the user for some input...
If I just use var input = prompt("dafa") everything works fine but the
box is put in the top left corner of the window. I need it to be
centered so... I was doing some research on the net (never really used
much JavaScript before) and was reading the only way to do this is by
making your own custom prompt. In my attempts of doing so I came up
with this code below. The problem I am having now is that when
onMaxLoad_Click() occurs the prompt appears for a split second and then
it goes back to being hidden. Please can someone help me??
1) why is the custom prompt disappearing??
2) is there a better solution than the way i am going about it??
IN HEAD........
<script>
function onMaxLoad_click()
{
document.getElementById("PromptBox").style.visibility = "visible";
}
function jsProcessPromptBox(selection)
{
if (selection == "true")
{
var maxLoad = document.getElementById("PromptBoxInput").value;
document.all.maxLoadBox.value = maxLoad;
}
document.all.PromptBox.style.visibility = "hidden";
}
</script>
..
..
..
in BODY.... Form1........
<div id="PromptBox" style="LEFT: 240px; POSITION: absolute; visibility:
hidden; TOP: 496px">
<div id="PromptBoxHead">What is the max load?</div>
<input id="PromptBoxInput" type="text"><button
onclick="jsProcessPromptBox('true')" type="button">OK</button><button
onclick="jsProcessPromptBox('false')" type="button">CANCEL</button>
</div>
If I just use var input = prompt("dafa") everything works fine but the
box is put in the top left corner of the window. I need it to be
centered so... I was doing some research on the net (never really used
much JavaScript before) and was reading the only way to do this is by
making your own custom prompt. In my attempts of doing so I came up
with this code below. The problem I am having now is that when
onMaxLoad_Click() occurs the prompt appears for a split second and then
it goes back to being hidden. Please can someone help me??
1) why is the custom prompt disappearing??
2) is there a better solution than the way i am going about it??
IN HEAD........
<script>
function onMaxLoad_click()
{
document.getElementById("PromptBox").style.visibility = "visible";
}
function jsProcessPromptBox(selection)
{
if (selection == "true")
{
var maxLoad = document.getElementById("PromptBoxInput").value;
document.all.maxLoadBox.value = maxLoad;
}
document.all.PromptBox.style.visibility = "hidden";
}
</script>
..
..
..
in BODY.... Form1........
<div id="PromptBox" style="LEFT: 240px; POSITION: absolute; visibility:
hidden; TOP: 496px">
<div id="PromptBoxHead">What is the max load?</div>
<input id="PromptBoxInput" type="text"><button
onclick="jsProcessPromptBox('true')" type="button">OK</button><button
onclick="jsProcessPromptBox('false')" type="button">CANCEL</button>
</div>