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 Quote Link to comment 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" ... Quote Link to comment 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.. Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
czukoman20 Posted February 24, 2008 Author Share Posted February 24, 2008 well i figured it out thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.