Conditional statement for dropdown

This topic contains 4 reply and 3 voices, and was last updated by Sk 9 years, 7 months ago
Viewing 4 Posts - 1 through 4 (of 4 total)
Author Posts
September 4, 2014 at 6:01 pm 26305
Sk Hi, I have a dropdown in one of the forms called "what" , depending on the selection they do (I put them values 1, 2 , their names are looking for, proposing), I want things to appear, but even with a simple test echo to try, I don't success to make it work ... Any help please ?
<?php 
	$what = get_post_meta( $post->ID, 'what');
	if( $what == 1 ){  
	echo ('LOOKING FOR');
	}elseif ( $what == 2 ){
	echo ('PROPOSING');	
		
		} ?>
September 7, 2014 at 2:13 pm 26389
Sekander Badsha Sekander Badsha

Hello Olivier,
Your question is not clear to me. Can you please send me some screenshots?

September 7, 2014 at 3:38 pm 26397
Olivier Olivier

Hi Sekander, thanks for the answer,

Basically here is the screenshot of the form, with the dropdown statement called “what” :
conditional

I want to display different things on the article page created if the user has selected the option 1, 2, 3 or 4 (values of the dropdown), on the above code, its is just an example with the “echo”,

But I don’t succeed checking which value of the dropdown the user has selected when he created the post,

Hope this is clear enough, let me know otherwise,

Thanks in advance,

Olivier

September 8, 2014 at 2:41 pm 26460
Olivier Olivier

Finally found the solution, I add it bellow in case it can help someone,
It’s working now with the following :

ID, ‘what’, true);

if($value == ‘1’) {
echo ‘test 1’;
} else {
echo ‘Nothing’;
}

?>

Thanks,

Olivier

September 9, 2014 at 12:03 pm 26514
Sk Sk

Hello Olivier,

Great work. you can do this by conditional logic. just create a text field or html field or any other you want after the dropdown field and use conditional logic on the field. check the image here

http://awesomescreenshot.com/0203gans26

Thank you

Viewing 4 Posts - 1 through 4 (of 4 total)