help with ajax array issue - ie only
Hi Guys,
I am currently trying to add some checked values to an array to eventually store in a db table. So I am using ajax .load function but having problems in IE.
Basically, in IE only the first check box can be added to the array, the following checkboxes with the same id / name wont add. Works fine in firefox. I am using the codeigniter framework.
Any ideas?
Heres the script....
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script language="javascript">
$(document).ready(function() {
$('input').change(function() {
var colourArray = { 'colour[]' : []};
$("#colour:checked").each(function() {
colourArray['colour[]'].push($(this).val());
});
var paintArray = { 'paint[]' : []};
$("#paint:checked").each(function() {
paintArray['paint[]'].push($(this).val());
});
$("#content").load("<?= site_url('/gallery/view/ajax') ?>", { 'choices[]': [colourArray['colour[]'], paintArray['paint[]']] } );
});
});
</script>
</head>
<body>
<div id="form">
<input type="text" id="message" name="message" />
<input type="checkbox" name="colour[]" id="colour" value="blue">blue<br>
<input type="checkbox" name="colour[]" id="colour" value="green">green<br>
<input type="checkbox" name="colour[]" id="colour" value="red">red<br>
<input type="checkbox" name="paint[]" id="paint" value="acrylic">Acrylic<br>
<input type="checkbox" name="paint[]" id="paint" value="oil">Oil<br>
<input type="checkbox" name="paint[]" id="paint" value="mixed">Mixed<br>
<input type="submit" id="submit" name="submit" value="submit" />
</div>
<div id="content">
<?php $this->load->view('gallery_choices') ?>
</div>
All help most appreciated.
Martyn.