Jump to content

Drag n Drop.... dropping checkbox


cesarcesar

Recommended Posts

I am using the awesome drag and drop script found at http://script.aculo.us/. Its a hog, but has lots of features. I have also added a modification that interacts to a db for reordering upon release of a dragable item. Within each dragable is a input checkbox. This checkbox holds a DB id value that is sent on submit. This process works fine in IE, but in FF the checkbox values dont get sent via GET, or POST. How do i get FF to react as i think it should, as IE does.

 

Just to clarify, If a row is dragged, that row's checkbox will not be sent in the POST vars. It reacts as if not checked. I need all checked boxes to POST. I have has some help on this here, http://www.webdeveloper.com/forum/showthread.php?p=745951#post745951.

I think the quy has a good idea of the direction but its not correct.

 

Heres a little bit of code from the project beyond the standard script.aculo.us library. Thanks,

 

Interface Script

<?php /*   needed for IE   */ ?>
<div id="page">
<div id="sale_row" class="section">
	<div id="item_1" class="lineitem" style="cursor: move;">example 1 <input type="checkbox" name="check_value[]" value="example1"></div>
	<div id="item_2" class="lineitem" style="cursor: move;">example 2 <input type="checkbox" name="check_value[]" value="example2"></div>
</div>
</div>

<?php /*   set JS outside *page* div   */ ?>
<script type="text/javascript">
// <![CDATA[
sections = ['sale_row'];

<?php /*   this watches for event changes like drag and drop action   */ ?>
Event.observe(window,'load',init,false);
function init() {

	<?php /*   add a sortable.create for each group level div   */ ?>
	Sortable.create('sale_row',{tag:'div', dropOnEmpty:true, containment:sections, only:'lineitem', onUpdate:updateData});
}

Sortable.create('page',{tag:'div',only:'section',handle:'handle'});
// ]]>
</script>

 

*Javasript* that formats and sends url to ajax db update page. When chekbox vars "params" are sent this works perfectly.

function updateData() {
var params = '';
var sections = document.getElementsByClassName('section');
sections.each(function(section) {
	params = Sortable.serialize(section.id);
	var ajax = new Ajax.Request(page_url,{
		method: 'post',
		parameters: params
	});
});
}

Link to comment
https://forums.phpfreaks.com/topic/52283-drag-n-drop-dropping-checkbox/
Share on other sites

  • 2 weeks later...

the problem i had with textboxes before is that you can not get their value by using js syntax: object.value, like you can most other fields.  I use this method to get checkbox values for ajax:

if (object.type == 'checkbox') {
    if (object.checked) postfields += object.name + '=1';
    else postfields += object.name  + '=0';
}

maybe the values are being sent in ff, but the actual values sent are different than explorer.  Use print_r($_SERVER); server side to see what was actually sent.  Does the page validate?  ff can be finickly about pages that don't validate, and I have found it more finicky about poorly formed FORMs.  Don't put the form tag inside a td unless the /form is in the same one, etc.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.