dropdown not validating

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Obadiah
Forum Regular
Posts: 580
Joined: Mon Jul 31, 2006 9:13 am
Location: Ashland, KY
Contact:

dropdown not validating

Post by Obadiah »

Im trying to validate my dropdown and I cant get why it wont validate,
the name of the dropdown's posted value is $areaReported. Its not checking to see that the user has anything other that "Select Area" selected and I cant figure out why

Code: Select all

<?php
if (($questnum >= 1) && ($areaReported != "Select Area")){
	echo $num_toggle_off;
	}
	else if(($questnum <= 1) || ($questnum >10) || ($areaReported == "Select Area")){
		echo $num_toggle_on; "<br>";
		echo "<p style=\"color:red\">Please enter valid number of records and/or Area to report on</p>";
	}

?>
thanks in advance for the assistance!
User avatar
mecha_godzilla
Forum Contributor
Posts: 375
Joined: Wed Apr 14, 2010 4:45 pm
Location: UK

Re: dropdown not validating

Post by mecha_godzilla »

I hope I'm not being thick here but it looks like you've got too many tests in there. Am I right in thinking that if $area_reported = "Select Area" and the number is between 1 and 10 then it's valid, and if not then the error message needs to be displayed?

The code that does what I'm describing looks like this:

Code: Select all

if (($questnum >= 1 && $questnum <= 10) && ($areaReported == "Select Area")){
	echo 'num_toggle_off';
} else {
	echo  'num_toggle_on' . "<br>";
	echo "<p style=\"color:red\">Please enter valid number of records and/or Area to report on</p>";
}
Is that what you need?

HTH,

Mecha Godzilla
Post Reply