javascript - How to insert appended dropdown into db -


anyone, long question bear me. have dropdown in form select country. there button add dropdown allows users select country. if user choose add dropdown, values of 2nd not inserted database, first value inserted. below dropdown.

                <div class="editor-field" id="mb">                       member countries                       <div id="jj">                         @html.dropdownlistfor(model => model.memberc, viewbag.lcountry selectlist, "--select--", new { @id = "tid0" })<br />                     </div> 

below button add dropdown

                <div id="test">                 </div>                 <input type='button' value='add' id='addbutton'> 

then have javascript work clone dropdown.

<script> $(document).ready(function ()     {         $("#addbutton").click(function () {             var elements = $("select[id!='template']");             var newelement = $("#jj").clone(true);             var count = elements.length;             if (count > 8) {                 alert('no more dropdowns');             }             else {                 newelement.attr('id', count);//rename new element refers     distinguished object instead of cloned object                 $("#test").append(newelement);             }         });          $("#removebutton").live("click", function () {             $(this).parents("div.jj:first").remove();             return false;         });     }); </script> 

heres dal links stored proc

    public static listofitems createschemecinsert(listofitems objlistofitems)     {         sqldatareader rdrdataaccess = null;         listofitems objlistofitemsdetails = null;         sqlconnection database = new sqlconnection(mycoodataconn.mycooconnectionstring);          //insert data in db         database.open();         sqlcommand databasecmd = new sqlcommand("sp_app_specific_schemecinsert", database);//name sp in database         databasecmd.commandtype = commandtype.storedprocedure;         databasecmd.parameters.add(new sqlparameter("@user_scheme_master_id", objlistofitems.msi));         databasecmd.parameters.add(new sqlparameter("@country_id", objlistofitems.memberc));           rdrdataaccess = databasecmd.executereader();         objlistofitemsdetails = new listofitems();          return objlistofitemsdetails;      } 

and stored procedure looks pretty normal

    insert [dbo].[app_specific_scheme_country]  (user_scheme_master_id, country_id) values (@schemeid,@country_id) 

so why first dropdown inserted table? , not 2nd, 3rd , forth. feel free ask if explanation not clear. sorry bad english.

i objlistofitems being populated 1 value, since isn't shown educated guess.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

spring cloud - How to configure SpringCloud Eureka instance to point to https on non standard port -

javascript - Bootstrap Popover: iOS Safari strange behaviour -