Checkbox Not Sending Complete Data via Post


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Checkbox Not Sending Complete Data via Post

  1. #1
    Join Date
    Feb 2007
    Posts
    79

    Checkbox Not Sending Complete Data via Post

    im using the script.aculo.us drag n drop script. i am having an issue getting a checkbox to POST its value if checked, once the row the checkbox is in is moved. I believe that once i change the position of a checkbox, it is no longer considered a child of the parent form. How can i get it back to being part of the original parent form?

    Another way of saying is... If i have 10 rows with checkbox's in each row, i check rows 1,2,3,4, then move row 1 to the 3 position (2,3,1,4), then submit, the returning POST array only has 2,3,4. How do i get 1 to be in the array as well?

    Interface Script
    Code:
    <?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.
    Code:
    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
    		});
    	});
    }

  2. #2
    Join Date
    Jun 2007
    Location
    Ukraine
    Posts
    7
    Sorry, your question is not 100% clear to me. Why you do not want just to move <form> element to include the check boxes? script.aculo.us is based on prototype library, so probably it just serializes the form and do not includes elements that are out of the form.

    Yes, that line:
    Code:
    params = Sortable.serialize(section.id);
    so, you can just add to params something like
    Code:
    params = Sortable.serialize(section.id)+'&check1='+$('check1').checked;
    But better just change the form element position.

  3. #3
    Join Date
    Feb 2007
    Posts
    79
    thanks for the suggestions i will try to implement them. I do not quit understand the prototype lib so well.

  4. #4
    Join Date
    Feb 2007
    Posts
    79
    params = Sortable.serialize(section.id)+'&check1='+$('check1').checked;
    Did not work. In fact it broke the JS reorder.

    Whats not working is, the value given to a particular rows checkbox, if check, reordered and submitted. The reordered rows checkbox value will not pass via POST. This is only an issue in Firefox.

  5. #5
    Join Date
    Feb 2007
    Posts
    79
    This guy has some good ideas about it. He is close but not right.

    http://www.webdeveloper.com/forum/sh...951#post745951

  6. #6
    Join Date
    Jun 2007
    Location
    Ukraine
    Posts
    7
    There are several ways to resolve the problem. I have just suggested one of them and I have assumed that you will define id to each check box (like check1, check2, check3). And sure you can add parameters to get check boxes array in $_POST. So, just decide what is better for you.

Similar Threads

  1. Replies: 0
    Last Post: 11-27-2006, 08:14 AM
  2. Replies: 0
    Last Post: 07-08-2002, 03:26 PM
  3. Replies: 1
    Last Post: 06-12-2001, 11:27 AM
  4. Replies: 1
    Last Post: 03-13-2001, 03:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center