javascript - remove html using jquery hide/show -
in option (html) menu added "other". if article isn't listed returns input using jquery, not send $_post , work
var_dump post ::
["link"]=> string(0) ""
code (mvc - codeigniter) ::
<div class="form-group"> <label class="col-md-4 control-label" for="assign_article">assign article menu</label> <div class="col-md-4"> <select name="link" class="form-control"> <?php foreach($get_data $showmenu) { ?> <option value="<?php echo $showmenu['id']; ?>"><?php echo $showmenu['title']; ?></option> <?php } ?> <option value="parent">other</option> </select> </div> </div> <!-- text input--> <div id="parentpermission" class="form-group"> <label class="col-md-4 control-label" for="menu_name">other:</label> <div id="parentpermission" class="col-md-4"> <input id="parentpermission" name="link" type="text" placeholder="menu name" class="form-control input-md"> </div> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"> </script> <script> $(document).ready(function () { togglefields(); //call first start out correct visibility depending on selected form values //this call our togglefields function every time selection value of our underage field changes $("#link").change(function () { togglefields(); }); }); //this toggles visibility of our parent permission fields depending on current selected value of underage field function togglefields() { if ($("#link").val() == 'parent') $("#parentpermission").show(); else $("#parentpermission").hide(); } </script> <!-- select basic --> <div class="form-group"> <label class="col-md-4 control-label" for="assign_article">add as</label> <div class="col-md-4"> <select id="status" name="status" class="form-control"> <option value="1">parent</option> <option value="0">child</option> </select> </div> </div>
html rendered ::
<div class="form-group"> <label class="col-md-4 control-label" for="assign_article">assign article menu</label> <div class="col-md-4"> <select name="link" id="link" class="form-control"> <option value="89">page title</option> <option value="parent">other</option> </select> </div> </div> <!-- text input--> <div id="parentpermission" class="form-group"> <label class="col-md-4 control-label" for="menu_name">other:</label> <div id="parentpermission" class="col-md-4"> <input id="parentpermission" name="link2" type="text" placeholder="menu name" class="form-control input-md"> </div> </div>
Comments
Post a Comment