How to get a text field value from the form in PHP by using jQuery Tagit -


i using jquery tags plugin , when user enter tags comma separated want tags after form submit using php.

my coding...

<?php        if(isset($_request['submit_tag'])) {     print_r($_request['tags']);      } ?> <!-- tags --> <script src="http://webspirited.com/tagit/demo/js/jquery.1.7.2.min.js"></script> <script src="http://webspirited.com/tagit/demo/js/jquery-ui.1.8.20.min.js"></script> <script src="http://webspirited.com/tagit/js/tagit.js"></script> <link rel="stylesheet" type="text/css" href="http://webspirited.com/tagit/demo/css/jquery-ui-base-1.8.20.css"> <link rel="stylesheet" type="text/css" href="http://webspirited.com/tagit/css/tagit-awesome-blue.css"> <script type="text/javascript">     $(function () {         $('#demo3').tagit({triggerkeys:['enter', 'comma', 'tab'], select:true});               $('#demo3gettags').click(function () {             showtags($('#demo3').tagit('tags'))         });          function showtags(tags) {             console.log(tags);             var string = "tags (label : value)\r\n";             string += "--------\r\n";             (var in tags)                 string += tags[i].label + " : " + tags[i].value + "\r\n";             alert(string);         }     }); </script> <!-- tags --> <form method="post" id="add_tag" action="" name="add_tag">     <button id="demo3gettags" value="get tags">get tags</button>     <ul id="demo3" name="tags[]"></ul>     <br />     <input type="submit" name="submit_tag" value="submit tag" /> </form> 

you can add following script in code.

$('input[type=submit]').click(function(){         tag = $('#demo3').tagit('tags');         console.log(tag);         (var in tag)           $('form').append("<input type='hidden' name='tags[]' value='"+tag[i].value+"' >");        }); 

so code below:

<?php           if(isset($_request['submit_tag'])){         print_r($_request['tags']);          } ?> <!doctype html> <html><head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>jquery tagit demo page (php/themeroller)</title> <script src="http://webspirited.com/tagit/demo/js/jquery.1.7.2.min.js"></script> <script src="http://webspirited.com/tagit/demo/js/jquery-ui.1.8.20.min.js"></script> <script src="http://webspirited.com/tagit/js/tagit.js"></script> <link rel="stylesheet" type="text/css" href="http://webspirited.com/tagit/demo/css/jquery-ui-base-1.8.20.css"> <link rel="stylesheet" type="text/css" href="http://webspirited.com/tagit/css/tagit-awesome-blue.css"> <script type="text/javascript">     $(function () {        $('#demo3').tagit();            $('#demo3gettags').click(function () {         showtags($('#demo3').tagit('tags'))       });       $('input[type=submit]').click(function(){         tag = $('#demo3').tagit('tags');         console.log(tag);         (var in tag)           $('form').append("<input type='hidden' name='tags[]' value='"+tag[i].value+"' >");        });       function showtags(tags) {         console.log(tags);         var string = "tags (label : value)\r\n";         string += "--------\r\n";         (var in tags)           string += tags[i].label + " : " + tags[i].value + "\r\n";         alert(string);       }     });   </script> <!-- tags --> <form method="post" id="add_tag" action="" name="add_tag">   <button id="demo3gettags" value="get tags">get tags</button>   <ul id="demo3" name="tags[]"></ul>   <br />   <input type="submit" name="submit_tag" value="submit tag"  />  </form> 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -