If statement using javascript inside php

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
adicooldude
New php-forum User
New php-forum User
Posts: 10
Joined: Mon Apr 07, 2014 2:26 am

Mon Apr 07, 2014 2:32 am

hi ,

try this it works .

include your 'div' before including php script

Code: Select all

if (200 <2000)
	echo "<script type='text/javascript'> document.getElementById('mySelect').style.display='none';</script>";
else
	echo "<script type='text/javascript'> document.getElementById('mySelect1').style.display='none';</script>";

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Tue Apr 08, 2014 6:49 pm

The better solution would be to add 'AND Emp_ID>=2000' to your query. That way you don't waste resources collecting and presenting unwanted records to then hide them. If you don't want to go that route, let me know and I'll show you another example that doesn't involve code duplication like the one already presented.

A good rule of thumb to avoid messy code is that if you're writing the same thing twice, you're writing it too many times.

Post Reply