Switching between DIVs
Posted: Wed Oct 03, 2007 4:29 pm
I've just started to learn javascript, well, I say learn, I mean I'm picking up snippets as I go along. I'm getting the general idea, but I think I'm trying to do something a little too advanced for me
, but it's probably really easy for you
I'm experimenting with AJAX, but I think that's really beside the point. What I'm trying to do:
There is a form with a text input box. If the box is empty I want the page to display one 'page' under the input box and if not then I want the page to display a different 'page' under the input box. I say 'page' because it's basically completely new content. Then when the user deletes the contents of the box the page will revert back to the original 'page', the one that was showing when the input box was empty to begin with.
My problem:
I can't figure out how to code into the script the check for whether the box is empty or not. I tried:
but that didn't work, because it just doesn't do anything when you enter data into the box. Then I tried by reversing the statement by adding an exclamation mark before the two equal signs which just made the script run as normal, as if the check wasn't present.
I'm guessing the problem lies in the check and that it only checks as soon as the page is loaded. If you can't understand what I'm trying to explain then I'll post the script.
Thanks in advance
I'm experimenting with AJAX, but I think that's really beside the point. What I'm trying to do:
There is a form with a text input box. If the box is empty I want the page to display one 'page' under the input box and if not then I want the page to display a different 'page' under the input box. I say 'page' because it's basically completely new content. Then when the user deletes the contents of the box the page will revert back to the original 'page', the one that was showing when the input box was empty to begin with.
My problem:
I can't figure out how to code into the script the check for whether the box is empty or not. I tried:
Code: Select all
if(variable == null)but that didn't work, because it just doesn't do anything when you enter data into the box. Then I tried by reversing the statement by adding an exclamation mark before the two equal signs which just made the script run as normal, as if the check wasn't present.
I'm guessing the problem lies in the check and that it only checks as soon as the page is loaded. If you can't understand what I'm trying to explain then I'll post the script.
Thanks in advance