Hello sir,
pls help me,
i want to echo only the selected checkbox value with single value of field2 when i click on submit button ,for example
field1 field2
............ ..........
chkbx1 20
chkbx2 10
chkbx3 15
submit
i have try if cond statement and foreach loop but its not working,pls reply me how to echo
Echo only selected Checkbox value.
Moderator: General Moderators
-
toushif.engg
- Forum Newbie
- Posts: 1
- Joined: Sat Nov 27, 2010 3:56 am
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Echo only selected Checkbox value.
I don't quite understand your question... are you saying you want to output the value of a checkbox?
-
shafiq2626
- Forum Commoner
- Posts: 88
- Joined: Wed Mar 04, 2009 1:54 am
- Location: Lahore
- Contact:
Re: Echo only selected Checkbox value.
Hi1
You can use this condition
Please check
You can use this condition
Code: Select all
if($_POST['check1']=='on'){ echo $_POST['check1']; }
if($_POST['check2']=='on'){ echo $_POST['check2']; }
if($_POST['check3']=='on'){ echo $_POST['check3']; }- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Echo only selected Checkbox value.
Foreach will only work with an array. Paste the html code for your formtoushif.engg wrote:i have try if cond statement and foreach loop but its not working,pls reply me how to echo
Code: Select all
<?php
// if the checkbox is ticked / checked you can check for this
// with isset()
if( isset($_POST['checkbox1']) ) { echo $_POST['checkbox1']; }
?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering