poleposters Posted September 17, 2008 Share Posted September 17, 2008 I have a form with several checkbox choices. <input type="checkbox" name="color[]" value="red" > <label for="red">Red</label> <input type="checkbox" name="color[]" value="yellow"> <label for="Yellow">Yellow</label> <input type="checkbox" name="color[]" value="blue" > <label for="Blue">Blue</label> And this is how I'm processing the info <?php include "mysql_connectratedr.php"; require_once ('config.inc.php'); include "admin/var.php"; $kink=$_POST["color"]; $n=count($link); for($i=0;$i<$n;$i++){ $query="INSERT INTO specialties (specialty_id,business_id,specialty) VALUES ('','1','$link[$i].')"; $query2=mysql_query($query);} ?> Everything works fine. Except I want to combine this form with some javascript. The problem is that the name of the checkboxes includes square brackets. name="color[]" The presence of the brackets cause the javascript to fail.(I've tried escaping them with no luck). The only solution I see is to remove the square brackets from the checkbox name. However when I do this, the form fails to process correctly. Is there a way to rewrite the form/script without using square brakets in the name? Link to comment https://forums.phpfreaks.com/topic/124572-processing-checkbox-form-with-php/ Share on other sites More sharing options...
kenrbnsn Posted September 17, 2008 Share Posted September 17, 2008 Give each checkbox a unique id which you can use in Javascript instead of the names. Ken Link to comment https://forums.phpfreaks.com/topic/124572-processing-checkbox-form-with-php/#findComment-643418 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.