czukoman20 Posted February 24, 2008 Share Posted February 24, 2008 <label> <span class="style6"> <input type="checkbox" name="sto" id="stocks" /> Stocks</span></label> <span class="style6"> <label> <input type="checkbox" name="com" id="commodities" /> Commodities</label> <label> <input type="checkbox" name="mort" id="mortgages" /> Mortgages</label> <label> <input type="checkbox" name="fin" id="financial planning" /> Financial Planning</label> </span><span class="style5"><label></label> </span> <label></label> <span class="style6"> <label> <input type="checkbox" name="edu" id="education" /> Ed. on Investing</label> </span></p> <p> <input name="email2" type="text" id="email2" size="45" /> </p> <p> <input name="phone" type="text" id="phone" size="45" /> </p></td> I have these checkboxes.. in my submit form. I would like to know how to manipulate them so that when one is checked on, it will echo that category how would i go about doing this Link to comment https://forums.phpfreaks.com/topic/92749-checkboxes/ Share on other sites More sharing options...
AndyB Posted February 24, 2008 Share Posted February 24, 2008 Instead of ... type="checkbox" name="edu" ... use an array for the checkboxes, then check the value returned when the form is submitted. ... type="checkbox" name="box[]" value="edu" ... Link to comment https://forums.phpfreaks.com/topic/92749-checkboxes/#findComment-475190 Share on other sites More sharing options...
czukoman20 Posted February 24, 2008 Author Share Posted February 24, 2008 Ok .... Im confused by use an array for the checkboxes, then check the value returned when the form is submitted. Could u possibly give me a working example code.. Link to comment https://forums.phpfreaks.com/topic/92749-checkboxes/#findComment-475191 Share on other sites More sharing options...
AndyB Posted February 24, 2008 Share Posted February 24, 2008 http://www.computing.net/webdevel/wwwboard/forum/1122.html Link to comment https://forums.phpfreaks.com/topic/92749-checkboxes/#findComment-475240 Share on other sites More sharing options...
czukoman20 Posted February 24, 2008 Author Share Posted February 24, 2008 ok well i did that... and now im stuck again.. cause its giving a avalue for the checked check boxes just a single word array if(isset($_POST['button'])) { $req_user_info = $database->getUserInfo($req_user); $email2 =$_POST['email2']; $companyname=$_POST['companyname']; $realname =$_POST['realname']; $last_name =$_POST['last_name']; $phone =$_POST['phone']; $market =$_POST['market']; foreach ($market as $marketname) { echo "$marketname\n"; } $message2 = $realname." $last_name has submitted a Advertise with us form to adworld.,\n\n" ."This persons information is as follows\n" ."----------------------------\n" ."Contact Name: $realname $last_name\n " ."Company: $compname\n " ."E-mail: $email2\n " ."Phone: $phone\n " ."This person is interested in the following categories\n" ."$marketname\n" ."----------------------------\n" .""; <input type="checkbox" name="market[]" value="Stocks" /> Stocks</span></label> <span class="style6"> <label> <input type="checkbox" name="market[]" value="Commodities" /> Commodities</label> <label> <input type="checkbox" name="market[]" value="Mortgages" /> Mortgages</label> <label> <input type="checkbox" name="market[]" value="Financial Planning" /> Financial Planning</label> </span><span class="style5"><label></label> </span> <label></label> <span class="style6"> <label> <input type="checkbox" name="market[]" value="Ed. on Investing" /> Ed. on Investing</label> </span></p> that is what i have this.. grant it the checkbox is in a form that works.. but im concentrating on the transfering the values when they are checked Thanks Link to comment https://forums.phpfreaks.com/topic/92749-checkboxes/#findComment-475261 Share on other sites More sharing options...
BlueSkyIS Posted February 24, 2008 Share Posted February 24, 2008 http://www.computing.net/webdevel/wwwboard/forum/1122.html loop over the elements of the array as in that tutorial? Link to comment https://forums.phpfreaks.com/topic/92749-checkboxes/#findComment-475268 Share on other sites More sharing options...
AndyB Posted February 24, 2008 Share Posted February 24, 2008 I don't understand the code you posted at all. Typically the idea is to organize your script thus: if (the submit button has been pressed) abstract the form data and process it otherwise (display the form) The example I pointed you too explained exactly how to determine which of an unlimited number of checkboxes in a form had been checked. Perhaps you need to review the article and review your code logic in light of the above. Link to comment https://forums.phpfreaks.com/topic/92749-checkboxes/#findComment-475271 Share on other sites More sharing options...
czukoman20 Posted February 24, 2008 Author Share Posted February 24, 2008 well i figured it out thanks Link to comment https://forums.phpfreaks.com/topic/92749-checkboxes/#findComment-475305 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.