PDA

View Full Version : radio button clicked show image.


QBall777
11-11-2009, 03:00 PM
Hi

Just need some help and direction on the following problem.

In the admin area the user can choose from three radio buttons. When they make thier choice and click the update button a message is displayed showing thier choice. (see below)
http://www.qbdesign.co.uk/golf.jpg

I'm not sure about this bit. On the public side I need the image associated with the radio button to show.

Example: If the course open button is clicked show course open image on the public page.

Do I need to store the images in a db or is there another way to do this.

Any help will be appreciated.

Thanks

abduraooft
11-11-2009, 03:06 PM
In the admin area the user can choose from three radio buttons. When they make thier choice and click the update button a message is displayed showing thier choice. (see below)
I'm not sure about this bit. On the public side I need the image associated with the radio button to show.
Dynamically add checked="checked" attribute to the radio buttons based on the value in the submitted data.

QBall777
11-11-2009, 07:49 PM
Hi abduraooft

Not sure I follow!!!

abduraooft
11-12-2009, 07:22 AM
Something like
<?php
$o=$c=$t='';
if(isset($_POST['course'])){
if($_POST['course']=='o'){
$o='checked="checked"';
$message="The course status is currently open"
}
elseif($_POST['course']=='c'){
$c='checked="checked"';
$message="The course status is currently closed"
}
else($_POST['course']=='t'){
$a='checked="checked"';
$message="The course status is currently temp"

}
}
?>

<label><input type="radio" name="course" value="o" <?php echo $o;?>/>Course open</label>
<label><input type="radio" name="course" value="c" <?php echo $c;?>/>Course closed</label>
<label><input type="radio" name="course" value="t" <?php echo $t;?>/>Course on tempory greens</label>

<?php
echo $message;
?>

Nischumacher
11-12-2009, 08:09 AM
in the admin area... when the user click the update button... a value would have been saved in the database... say dbCourseValue is open/closed/temps or 0/1/2... name your course images like course_open.jpg/course_closed.jpg/course_temps.jpg or course_0.jpg/course_1.jpg/course_2.jpg...

on the public side fetch this value... and assign to the imageurl property of the image...

imgCourse.ImageUrl = 'images/course_' & dbCourseValue & '.jpg'

QBall777
11-13-2009, 07:35 AM
That's great Nischumacher, i'm sure I can work it out from your example.

Cheers