Welcome Guest, Not a member yet? Register   Sign In
Javascript array to codeigniter controller
#10

[eluser]bennyhill[/eluser]
@Nick Husher - I have a list of almost 300 attendees, do you think your option is still viable?

I found some code online and adapted it and it seems to work the way I want. Not exactly sure why though.

Code:
[removed]
function moveOptions(theSelFrom, theSelTo)
{
    var tableMax = 10;
    var tableCount = 0;
    var table = document.getElementById('sel4');
    var selLength = theSelFrom.length;
    var selectedText = new Array();
    var selectedValues = new Array();
    var selectedCount = 0;
    
    var i;
    
    if(theSelTo.id == 'sel4' && tableCount >= tableMax)
    {
        alert('Table only seats ' + tableMax);
    }else{
        // Find the selected Options in reverse order
        // and delete them from the 'from' Select.
        for(i=selLength-1; i>=0; i--)
        {
            if(theSelFrom.options[i].selected)
            {
                selectedText[selectedCount] = theSelFrom.options[i].text;
                selectedValues[selectedCount] = theSelFrom.options[i].value;
                deleteOption(theSelFrom, i);
                selectedCount++;
            }
        }
        
        // Add the selected text/values in reverse order.
        // This will add the Options to the 'to' Select
        // in the same order as they were in the 'from' Select.
        for(i=selectedCount-1; i>=0; i--)
        {
            addOption(theSelTo, selectedText[i], selectedValues[i]);
        }
            
        if(NS4) history.go(0);

    }
}

function selectAllOptions(selStr)
{
  var selObj = document.getElementById(selStr);
  for (var i=0; i<selObj.options.length; i++) {
    selObj.options[i].selected = true;
  }
}
[removed]
<div id="tableNames">

<table border="0">
    <tr>
        <td>
            <h3>Current Attendee List</h3>
            <select id="sel3" size="20">
                &lt;?php
                    foreach($attendee->result() as $row)
                    {
                        echo '<option value="'.$row->name;
                        if($row->guest){
                            echo ','.$row->guest.'">'.$row->name.' & '.$row->guest.'</option>';
                        }else{
                            echo '">'.$row->name.'</option>';
                        }
                    }
                ?&gt;
            </select>
        </td>
        <td align="center" valign="middle" id="centerButtons">
            &lt;form&gt;
            &lt;input type="button" value="--&gt;"
            &gt;&lt;br />
            &lt;input type="button" value="&lt;--"
            &gt;
            &lt;/form&gt;
        </td>
        <td>
            <h3>Your Table</h3>
            &lt;form action="&lt;?php echo $base.'registration/submitTable'; ?&gt;" method="post"&gt;
            <select name="selPHP[]" id="sel4" multiple="multiple" size="10" />
            <br />
            &lt;input type="submit" value="Submit" /&gt;
            &lt;/form&gt;
        </td>
    </tr>
</table>


Messages In This Thread
Javascript array to codeigniter controller - by El Forum - 10-16-2008, 07:15 AM
Javascript array to codeigniter controller - by El Forum - 10-16-2008, 08:31 AM
Javascript array to codeigniter controller - by El Forum - 10-16-2008, 08:52 AM
Javascript array to codeigniter controller - by El Forum - 10-16-2008, 06:35 PM
Javascript array to codeigniter controller - by El Forum - 10-17-2008, 01:52 AM
Javascript array to codeigniter controller - by El Forum - 10-17-2008, 01:59 AM
Javascript array to codeigniter controller - by El Forum - 10-17-2008, 02:06 AM
Javascript array to codeigniter controller - by El Forum - 10-17-2008, 02:11 AM
Javascript array to codeigniter controller - by El Forum - 10-17-2008, 06:41 AM
Javascript array to codeigniter controller - by El Forum - 10-17-2008, 06:42 AM
Javascript array to codeigniter controller - by El Forum - 10-17-2008, 07:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB