Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Multiple selects in a form
#1

[eluser]Clooner[/eluser]
I've ran into this problem yesterday and I couldn't figure out what was wrong with it. Today I started to try and find out what is wrong with it, but no luck so far.

The situation: I'm using TWO SELECT MULTIPLES to assign multiple categories to an product.

This is my form and for now I am just using the profiler to check for the post values. The weird thing however is that only sometimes the post values get submitted. No errors, no faults just no post values get submitted. There are no redirects in the code and it's all default CI2.0.2 code. I've been looking at my code which seems valid but somehow the values only get submitted once or twice out of 10 times. I figured it must be something to do with the XSS or CSRF protection so I disabled them all but still I'm not getting the desired results. I thinks this must be a little mistake on what messes it all up but somehow I'm not able to see it
Code:
<form action="http://localhost/nxip/product_to_brands_ctrl/child_to_parents/1" method="post" accept-charset="utf-8" id="edit_product_to_brand_form">
<div class="hidden">
&lt;input type="hidden" name="ci_csrf_token" value="2f19e61b35deb14ba7fe5b38d3eb3a38" /&gt;
</div>
<div style="width:45%; float:left; display:block;">
    <h1>Product</h1>
    <select size="17" style="width:100%;" name="for_child_id[]" class="child_select" multiple>
    </select>
</div>

<div style="width:10%; float:left; text-align:center;">
<br/><br/><br/>
    <a href="#" class="move_selected_left">&lt;&dash; Selected</a><br/><br/>
    <a href="#" class="move_all_left">&lt;&dash; All</a><br/><br/>

    <a href="#" class="move_selected_right">Selected &dash;&gt;</a><br/><br/>
    <a href="#" class="move_all_right">All &dash;&gt;</a><br/><br/>
</div>

<div style="width:45%; float:right;">
    <h1>Brands</h1>
    <select size="17" style="width:100%;" name="parent_ids[]" class="parents_select" multiple>
        <option value="9">Valvoline</option>
        <option value="10">Tirex</option>
        <option value="11">3m</option>
        <option value="12">TRW</option>
        <option value="13">SKF</option>
    </select>
</div>
<br style="clear:both;"/>
    <div>&lt;input class="button" type="submit" value="Save product_to_brand"/&gt;&lt;/div>
&lt;/form&gt;
Why are my values only posted to the page once or twice out of ten times?
#2

[eluser]Clooner[/eluser]
I found the answer and indeed it was a simple thing.

obviously when I submit the form it only send the selected values. Once I had my head wrapped around this concept it was a piece of cake. I created an event handler with js that selects all the values in both the select boxes when the form is submitted.




Theme © iAndrew 2016 - Forum software by © MyBB