By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,581 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Dec 7 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
tlyczko wrote:
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.messag e.value)">
</form>

[...]
--
Rob
Dec 7 '05 #2

P: n/a
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

Dec 8 '05 #3

P: n/a
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

Dec 8 '05 #4

P: n/a
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

Dec 8 '05 #5

P: n/a
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

Dec 8 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.