hide & show divs with different text msgs in the same place on the screen???

T

tlyczko

Hello, I've searched on toggling divs and didn't really find what I was
looking for, I saved a bunch of different threads.

I have a form with several different text boxes for things like dates,
numbers, etc. arranged in a table, each row has the same kind of text
boxes for data entry (10 rows probably).

I want to have a separate section above the form where I can toggle a
div containing an appropriate error message to appear after the
onchange event fires for the text box.

The thing is, I want all the divs with their different text messages to
appear in the same place and disappear from the same place above the
form instead of different places on the form or web page.

Well, they don't have to be multiple divs, but there are multiple
different error messages that should appear depending where the user is
typing...

Example: 'wrong format,' 'month must be between 1 and 12,' etc. Of
course the messages will be nicer than this.

This basically just has to work in IE 6.x, it's an intranet form, well
maybe also Firefox (the best!).

Thank you, Tom
 
R

RobG

tlyczko said:
Hello, I've searched on toggling divs and didn't really find what I was
looking for, I saved a bunch of different threads.

I have a form with several different text boxes for things like dates,
numbers, etc. arranged in a table, each row has the same kind of text
boxes for data entry (10 rows probably).

I want to have a separate section above the form where I can toggle a
div containing an appropriate error message to appear after the
onchange event fires for the text box.

The thing is, I want all the divs with their different text messages to
appear in the same place and disappear from the same place above the
form instead of different places on the form or web page.


Why not have one div and just change the message?

<script type="text/javascript">

function showMessage(id, msg)
{
if (document.getElementById){
var mBox = document.getElementById(id);
if (mBox.firstChild) {
mBox.firstChild.data = msg;
} else {
if (mBox.appendChild && document.createTextNode){
mBox.appendChild(document.createTextNode(msg));
} else if(mBox.innerHTML){
mBox.innerHTML = msg;
}
}
}
}

</script>

<div id="messageBox"
style="border: 1px solid red; width: 20em; height: 3em"></div>
<form action="">
<input type="text" name="message">
<input type="button" value="Show message"
onclick="showMessage('messageBox',this.form.message.value)">
</form>

[...]
 
T

tlyczko

Ah...thank you...You are a *genius* with this...That's the same thing I
was talking about, only you expressed it differently. I will test this
out, see how it works, etc., then modify it to run from the onchange
event as opposed to clicking a button.

I will use it to display error messages when the end user enters data
into a form field.

Thank you again, Tom
 
T

tlyczko

Ah...thank you...You are a *genius* with this...That's the same thing I
was talking about, only you expressed it differently. I will test this
out, see how it works, etc., then modify it to run from the onchange
event as opposed to clicking a button.

I will use it to display error messages when the end user enters data
into a form field.

Thank you again, Tom
 
T

tlyczko

Ah...thank you...You are a *genius* with this...That's the same thing I
was talking about, only you expressed it differently. I will test this
out, see how it works, etc., then modify it to run from the onchange
event as opposed to clicking a button.

I will use it to display error messages when the end user enters data
into a form field.

Thank you again, Tom
 
T

tlyczko

Ah...thank you...You are a *genius* with this...That's the same thing I
was talking about, only you expressed it differently. I will test this
out, see how it works, etc., then modify it to run from the onchange
event as opposed to clicking a button.

I will use it to display error messages when the end user enters data
into a form field.

Thank you again, Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top