Connecting Tech Pros Worldwide Forums | Help | Site Map

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

tlyczko
Guest
 
Posts: n/a
#1: Dec 7 '05
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


RobG
Guest
 
Posts: n/a
#2: Dec 7 '05

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


tlyczko wrote:[color=blue]
> 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.[/color]


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
tlyczko
Guest
 
Posts: n/a
#3: Dec 8 '05

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


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

tlyczko
Guest
 
Posts: n/a
#4: Dec 8 '05

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


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

tlyczko
Guest
 
Posts: n/a
#5: Dec 8 '05

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


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

tlyczko
Guest
 
Posts: n/a
#6: Dec 8 '05

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


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

Closed Thread