Petesman wrote:
Thanks for replying Fred. The application i am making is on a much
larger scale than what i posted. I need to have a prompt come up
because it is necessary to the client. What it does is simply add the
maxLoad (lbs...but it wont matter to the engineers..they know this
already) to the end of a label already on the page with a part number
If they are real engineers, the should insist that the units be
specified. Even accountants put ($) on every column that deals with
dollars, or (hrs) on every column dealing with hours, etc. Any lurking
engineers care to comment?
in it. I posted a watered down version of what I am trying to do for
simplicity. I understand I need to validate but I haven't even reached
that point yet.
That point should be very early in the process, you should validate
from the very outset. Specify what you want, there are lots of
previous posts to show how to validate for say a float with three
significant digits. It takes perhaps 5 lines to test the input and
respond appropriately if required. And done once, you can make a "test
input" function that tests all inputs with a sinlge call.
For some reason or other the PromptBox is disappearing.
I suspect that the button you are using does not have type="button"
specified. By default, all buttons are submit buttons unless you
specify otherwise using "type". So when your "show the prompt" button
is clicked, the js runs then the form is submitted, which will cause
the page to re-load and hide the prompt again. Look in the address bar
after clicking the "reveal" button.
<URL:http://www.w3.org/TR/html4/interact/forms.html#edef-BUTTON>
So check the button type="button" in the HTML.
[...] Also thank you Michael for the tips.. they should be of much help when
I get this stupid thing fixed.
I included Mike's method to position the prompt, but as you can see it
puts the top left corner in the centre of the page, you'll have to allow
for the width/height of the box to get it centered.
As for Mike's comment:
You have also mixed up buttons and form elements,
Umm, what's that supposed to mean?
What I meant to write was that it's better (to me) to use input buttons
rather than button buttons. Input buttons tend to look better, unless
you are using the extra capability of button buttons (mmm, don't think
that's much clearer, but what the heck).
Included below is code as close as possible to your original. Note you
may want to make the document.all substitution global, or ditch
document.all altogether if this is an intranet app and you don't expect
any old IE browsers to use it.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html><head><title>Copy Text & Values</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
..promptBox {
text-align: center;
position: absolute;
height: 4em;
width: 12em;
left: 50%;
top: 50%;
margin-left: -(width/2)em;
margin-top: -(height/2)em;
z-index: 100;
foreground-color: black;
background-color: #ddddee;
border-top: 1px solid #333366;
border-left: 1px solid #333366;
border-right: 3px solid #333366;
border-bottom: 3px solid #333366;
}
body {
font-family: sans-serif;
}
</style>
<script type="text/javascript">
function onMaxLoad_click() {
if (document.all && !document.getElementById) {
document.getElementById = function(id) {
return document.all[id] }
}
document.getElementById("PromptBox").style.display = '';
}
function jsProcessPromptBox(selection) {
if (document.all && !document.getElementById) {
document.getElementById = function(id) {
return document.all[id] }
}
if (selection == true) {
document.getElementById('MaxLoadBox').value =
document.getElementById('PromptBoxInput').value
} else {
document.getElementById('PromptBoxInput').value =
document.getElementById('MaxLoadBox').value;
}
document.getElementById("PromptBox").style.display = 'none';
}
</script>
</head><body onload="jsProcessPromptBox(false);">
<form action=""><p>
<!-- this makes the prompt appear -->
<button type="button" onclick="
onMaxLoad_click();
">Make the prompt appear"</button>
<!-- a text input to show that the input value went somewhere -->
<input type="text" name="MaxLoadBox" id="MaxLoadBox"
size="10" readonly>Max Load (lbs)
</p>
<div id="PromptBox" class="promptBox">
<div id="PromptBoxHead">Enter max load (lbs)</div>
<input name="PromptBoxInput" id="PromptBoxInput" type="text"><br>
<input type="button" value="Ok" onclick="
jsProcessPromptBox(true)
">
<input type="button" value="Cancel" onclick="
jsProcessPromptBox(false)
">
</div>
</form>
</body></html>
--
Fred