Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...It is good to know that there are groups such as this willing to share knowledge in this money driven economy..."

Geography

Where in the world do Tek-Tips members come from?

Getting dynamic form values.Helpful Member! 

ag1060 (Programmer)
14 May 12 9:31
Hello coders,

I'm trying to get form values from dynamic form (screenshot: http://oi49.tinypic.com/25ox9c3.jpg)

When the user clicks submit, I want to get the textfield value and the value of the checkbox right next to each other like:

Stage1 - 1 (checked)
Stage2 - 0 (unchecked)

So far, I have the code to get the textfields values but not the checkbox values next to each other:

CODE

while (list ($key,$status) = @each ($_POST['stage'])){ //echo "$val,"; while (list ($key,$status1) = @each ($_POST['stage_status'])){ echo "$status<br>"; echo "$status1<br>"; } }

I know that's some bad coding practice but I was wondering how can I achieve what I've stated with neat coding. I know there's a way and any help is appreciated.


Thanks in advance.
Helpful Member!  jpadie (TechnicalUser)
14 May 12 9:40
only checked checkboxes will be submitted. so make sure that you explicitly number your checkboxes and fields as so

CODE

<form> <input type="text" name="text[0]" /><input type="checkbox" name="completed[0]" value="1"/> ... </form>

then in your receiving script

CODE

foreach ($_POST['text'] as $key=>$val): printf("%s - %s <br/>", htmlspecialchars(trim($val)), isset($_POST['completed'][$key]) ? "1 (checked)" : "0 (unchecked)"); endforeach;
ag1060 (Programmer)
14 May 12 9:56
jpadie,

I appreciate the help and it works just fine now :)


Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close