Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 06-08-2005, 10:08 AM 90 checkboxes
Experienced Talker

Posts: 36
Trades: 0
hi

i got 90 checkbox with 90 textfields in form, and i need process only selected checkboxes with textfield on next page and email...

example i got:

<input name="1" type="checkbox" id="1" value="checkbox"> with <input name="number1" type="text" id="number1">

<input name="2" type="checkbox" id="2" value="checkbox"> with <input name="number2" type="text" id="number2">

.....

<input name="90" type="checkbox" id="90" value="checkbox"> with <input name="number90" type="text" id="number90">

how can do that with some loop?
crodream is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-08-2005, 11:16 AM
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
Trades: 0
$i=1;
foreach($_POST as $key => $val){
if(!empty($_POST[$i]) && !empty($_POST['number'.$i])){
// do_something
}else{
// nothing set
}
$i++;
}

ibbo
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Linux user #349545 :
(GNU/Linux)iD8DBQBAzWjX+MZAIjBWXGURAmflAKCntuBbuKCWenpm XoA7LNydllVQOwCf
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Old 06-08-2005, 11:42 AM Try with Excel Auto Numbering
Junior Talker

Posts: 1
Trades: 0
Hello, sorry my english is not the best!!

Try it with Auto Numbering with Excel
1. Cell: <input name="
2. Cell: 1
3. Cell" type="checkbox" id="
4. Cell: 1
5. Cell:" value="checkbox"> with <input name="
6. Cell:number1
7. Cell: " type="text" id="
8. Cell: number1
9. Cell:">

<input name="2" type="checkbox" id="2" value="checkbox"> with <input name="number2" type="text" id="number2">

TXT File is attached!!!

by maste
Attached Files
File Type: txt option_numbers.txt (10.2 KB, 11 views)
maste is offline
Reply With Quote
View Public Profile
 
Old 06-08-2005, 11:47 AM
Experienced Talker

Posts: 36
Trades: 0
i need process only selected checkboxes with textfield on next page and email...
crodream is offline
Reply With Quote
View Public Profile
 
Old 06-08-2005, 05:37 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Heres a short script I wrote that should illustrate a nice easy way of doing this:

PHP Code:
<html>
<body>
<?php

if(isset($_POST['submit'])) {
  echo
"<pre>\n";
  
print_r($_POST);
  echo
"<\pre>\n";

}
else {
  echo 
"<form action='".$SERVER['PHP_SELF']."' method='POST'>";
  for(
$i=0$i<50$i++) {
    echo 
"<input type='checkbox' name='boxes[$i]' /><br />";
  }
  echo 
'<input type="submit" name="submit" value="Go" />';
  echo 
"</form>";
}
?>
</body>
</html>
Code:
Array
(
    [boxes] => Array
        (
            [9] => on
            [14] => on
            [18] => on
            [22] => on
            [23] => on
            [26] => on
            [28] => on
            [32] => on
        )

    [submit] => Go
)
You can create the checkboxes with the name boxes[0], boxes[1] etc, then when you read the post variables after the form is submitted, you get one array called boxes, with all the indexes of the boxes you ticked set to on.
You can then do something like

PHP Code:

foreach($boxes as $key => $value) {
  echo 
"Processing checkbox $key<br />";

which would print

Code:
Processing checkbox 9
Processing checkbox 14
Processing checkbox 18
Processing checkbox 22
Processing checkbox 23
Processing checkbox 26
Processing checkbox 28
Processing checkbox 32
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 06-09-2005, 02:12 AM
Logical Program's Avatar
Super Talker

Posts: 130
Location: Atlanta, Georgia
Trades: 0
Here's a piece of code I wrote... Assuming checkbox's are named 1,2,3, etc... And textboxes are named number1,number1,number3, etc., corresponding with the checkbox with the same number.


Code:
<?

$current = 1;
while(list($checkbox, $checkstate) = each($_POST)){
    if ($checkstate === 'on' && $_POST[number$current] <> ''){
        echo '
            '.$checkbox.': '.$checkstate.' .......... '.$_POST[number$current].' (SUCCESS!)<br />
        ';
    } elseif ($checkstate === 'on' && $_POST[number$current] === ''){
        echo '
            '.$checkbox.': '.$checkstate.' .......... BLANK TEXT FIELD! (FAILURE!) <br />
        ';
    }
    $current++;
}

?>
__________________

Please login or register to view this content. Registration is FREE
- For all of your website programming and design needs, make the logical choice. Logical Assistance For Real-World Clients.

Last edited by Logical Program; 06-09-2005 at 02:16 AM..
Logical Program is offline
Reply With Quote
View Public Profile Visit Logical Program's homepage!
 
Old 06-09-2005, 11:42 AM
Experienced Talker

Posts: 36
Trades: 0
thanks
crodream is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to 90 checkboxes
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25202 seconds with 13 queries