javascript - Submitting Data from tokeninput.js -
i have set https://github.com/loopj/jquery-tokeninput on 1 of web sites.
i trying allow users of sites create list number of options give them.. once user done selecting items , click submit no values back.
can let me know doing wrong..
html
<div> <input type="text" id="demo-input" name="name" /> <input type="submit" value="submit" /> </div>
js
<script type="text/javascript"> $(document).ready(function() { $("#demo-input").tokeninput("json.php"); }); </script>
php
$name =$_post["name"]);
this doing far around issue..
as user adds , removes items list using onadd , ondelete functions add id's hidden field .. once id's populated can use standard $_post[] command in php read values
here sample of code else might have same issue
html
<div> <input type="text" id="list_of_items" name="list_of_items" /> <input type="hidden" id="list_of_items_by_id" name="list_of_items_by_id" /> <input type="submit" value="submit" /> </div>
js
$(document).ready(function(){ var field_value = $("#list_of_items_by_id").val(); $("#list_of_items").tokeninput("json.php",{ hinttext: "start typing name of item", tokenvalue:"item_id", onadd: function (item) { var field_value = $('#list_of_items_by_id').val(); if (field_value != ""){ $('#list_of_items_by_id').val(field_value+","+ item.item_id); }else{ $('#list_of_items_by_id').val(item.user_id); } }, ondelete: function (item) { var field_value = $('#list_of_items_by_id').val().replace(',,',',').replace(item.user_id,''); $('#list_of_items_by_id').val(field_value); } }); });
Comments
Post a Comment