Forum Moderators: open

Message Too Old, No Replies

Stopping entire page from displaying based on conditional statement

         

dreaming of nascar

12:10 am on May 17, 2003 (gmt 0)

10+ Year Member



I am trying to make a page that only displays some of the information if a certain conditional statement is met. I am sure that this makes no sense to any of you so let me write a simple program to help...

<HTML>
.
.
.
.
<SCRIPT>
if(conditionalStatement == 0){
stop printing HTML to screen here
}
</SCRIPT>
If conditionalStatement was not met...
.
.
.
.
.
</HTML>

I hope that this makes some sense. The way I have it working now, is pathetic and not reliable at all. I hope that this is possible.
The way I have it now is like above, but instead of the if like above, I have

if(conditionalStatement!= 0){
Print the stuff I dont want if conditionalStatement = 0.
}

I do a document.write() statement with a <FORM> inside and the <FORM> does not work. I click on my submit button and there is nothing in the query string. I think this is a bad way to do it anyway. It makes the HTML inside the document.write() very confusing and hard to edit.
Anyways, I hope that someone can offer some advise with this.
Thanks in advance

D O N

msr986

12:25 am on May 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If javaScript is not up to the task, then you may need to use a server side scripting language such as perl, to create these pages.

ShawnR

12:28 am on May 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi DON

One way to do it would be to put the material you want to conditionally display in a div, and turn the 'visibility' of the div on or off.

I don't think the problem with your form is related to the 'document.write' method, though, unless you didn't escape some nested quote marks.

Shawn

msr986

12:37 am on May 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> One way to do it would be to put the material you want to conditionally display in a div, and turn the 'visibility' of the div on or off.

I see two potential problems with that solution, browser compatibility, and search engine bans for hidden text.

If it was me, I'd try something else, IMHO.

ShawnR

1:18 am on May 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As far as I know, you won't get 'banned' for using hidden text in a legitimate way. As far as I know, the hidden text might be ignored in the indexing, but the site won't get banned. (To see what I mean, check out the page rank on this: www.meyerweb.com/eric/css/edge/popups/demo.html)

I agree with msr986's other point: browser's with Javascript turned off and some old browsers won't get the effect you want. So if you have php or perl on the server, that would be a better way.

Shawn

msr986

3:56 am on May 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ShawnR,

There is a lot of talk that Google is about to implement new hidden text filters over the next few weeks or months. This has many SEO's concerned. How well do you think a filter can determine that an entire hidden div is legitimate? Personally, I don't think it's worth taking the chance until we know more about what's going to happen.

ShawnR

4:16 am on May 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Agreed... Might be an interesting question to pose on the google forum.

Personally I think that the algorithms would have to be good enough to not make such a stupid blunder as banning a site such as MeyerWeb's css dev edge. If it were, then google's results would become unreliable, and google would have to improve the algorithms or lose some of their share of the search engine users. Lots of sites use hidden divs or layers for perfectly legitimate purposes, and I am confident that before google implements, they test. That said, I know we live in the real world., so you are right, no point taking chances.

Shawn

MWpro

4:36 am on May 17, 2003 (gmt 0)

10+ Year Member



IMO, the easiest way to do this would be with php and includes. But this also depends on how many pages need to use this... if it is a lot then you may want to do it with a database.

Here is a simple example of how to do it with includes:

Put the hide/show content into a file called whatever.php.

In the page that is shown/hidden, the code would look something like this.

<?php
$con = 2;
if ($con == 1)
{
include ("whatever.php");
}
?>

If you don't want to use an include, you can always just echo the content or call it up from a database. Also you should consider how you are going to set $con to 1; does the user set it or do you? An advantage of this is that you don't have to worry about hidden text with google... disadvantage would be having to convert to .php extensions.