To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > Tools > Dreamweaver

Dreamweaver In need of help with Dreamweaver?

Reply
 
Thread Tools Rate Thread Display Modes
Old 10-16-2003, 05:30 PM   #1
andyl
Junior Member
 
Join Date: Oct 2003
Location: Bologna/Italy
Posts: 1
Problems with dynamically created checkbox

Hi there,
Hope someone can help with this

The problem I have concerns a dynamically created table/form which pulls in results from a user search of a mysql database. This works fine and pulls in results (title/author/isbn/price) and dynamically creates the table dependent upon how many results are found. For each result there is a dynamically created checkbox, which is bound to a unique field from the database(in this case isbn).

My problem then is: the dynamically created checkbox submits an isbn value to the next page - an order form. However I need that a user can select a number of checkboxes from the table. At the moment, each selection overwrites the other. It may be vary obvious - but I need to work out some way of storing the checkbox info in an array that gets submitted to my order form page.

at the moment the code for my checkbox within the html form is:


<input name="isbn_input" type="checkbox" id="isbn_input" value="<?php echo $row_Rs_panozzo_search['isbn']; ?>" />
</font></td>

This works passing one value through to my order form, but I need to set it up so it passes multiple values.

Hope I've explained this clearly enough

Thanks!
Andy
andyl is offline   Reply With Quote
Old 10-17-2003, 10:01 PM   #2
TheIceman5
Senior Member
 
Join Date: Jun 2003
Posts: 392
dunno, need to see some more code.
if u posted this in the corret forum it would be most probably answered by now, not many people visit this section of the forum.
TheIceman5 is offline   Reply With Quote
Old 10-18-2003, 10:12 PM   #3
tshafer
Programmer Extraordinaire
 
Join Date: Aug 2002
Location: Wilmington, NC
Posts: 67
both the name and id for the checkbox need to be "isbn_input[]". This will make any results populate an array.

---tom
__________________
Tom
Port City Community Church
tshafer is offline   Reply With Quote
Old 10-23-2003, 08:35 PM   #4
bodzan
Senior Member
 
Join Date: May 2003
Location: Novi Sad, Serbia
Posts: 576
An idea

As the previous member said, but one more thing:

You might want the script on the form processing page to check all of your checkboxes in order to see whether they are checked and then take an apropriate action...

Say you have dinamically formed an form with sayx checkboxes...

I don't know how you dinamically write them in your page but lets say something like (this is PHP coding but the idea is there):

$i=0;
while($i<$total){
echo "<input type=\"checkbox\" name=\"check_bow[".$i."]\" value=\"whatever\">";
$i++;
}

This way you would have printed out $total number of checkboxes on that page...
The important thing is that they ALL have different name that goes like "check_box[number]"...

This way you won't get the only-one-selectable-form...

About the checking:

This while loop creates an variable $i that is the number of checkboxes indexes (that is number of checkbox fields - 1)...
You might want to know this number (if you don't already know it) and you might to put in an hidden field named, say "howMany" in order to know this value and to take it to form processing page... The value should be like $i or $total-1 or number of fields if you know it. Either will get you there...

On the form processing page you could do something like this to check if they are checked and to do whatever you want to do with them:

$i=0; //don't mistake this one with the previous $i because it is on other page
while($i<$howMany){
if($check-box[$i]!=""){//if it's checked
//do whatever with the value of it...
}
$i++;

}

Hope this helps...
__________________
I know that I don't know nothing...
bodzan is offline   Reply With Quote
Old 10-23-2003, 08:38 PM   #5
bodzan
Senior Member
 
Join Date: May 2003
Location: Novi Sad, Serbia
Posts: 576
umm, I made two mistakes in my previous reply... ^_^

If the name of the box is check_bow (instead of check_box I wanted) in the second while loop's if statement the variable you check is $check_bow (or check_box as I wanted) ...


HE HE HE
__________________
I know that I don't know nothing...
bodzan is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 06:40 PM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.