Note that there are some explanatory texts on larger screens.

plurals
  1. POSplit tagit input data into multiple rows
    primarykey
    data
    text
    <p>I am using jquery.webspirited.coms tagit jquery, which is working correctly in the sense of creating the tags, separating on the front end, but when I POST the data, it's only posting the last tag as the value to the database..</p> <p>I can't find any documentation on how to correctly install the addon apart from what code to put in the header etc, here is the header code.</p> <pre><code>&lt;script type="text/javascript"&gt; $(function () { $('#topic').tagit(); $('#topicGetTags').click(function () { showTags($('#topic').tagit('tags')) }); $('input[type=submit]').click(function(){ tag = $('#topic').tagit('tags'); console.log(tag); for (var i in tag) $('form').append("&lt;input type='hidden' name='tags[]' value='"+tag[i].value+"' &gt;"); }); function showTags(tags) { console.log(tags); var string = "Tags (label : value)\r\n"; string += "--------\r\n"; for (var i in tags) string += tags[i].label + " : " + tags[i].value + "\r\n"; alert(string); } }); &lt;/script&gt; </code></pre> <p>The input</p> <pre><code>&lt;ul id="topic" name="tags[]"&gt;&lt;/ul&gt; </code></pre> <p>The tagit.js file itself has almost 500 lines, so rather than copy/paste it here, here is a link to it.</p> <p><a href="http://webspirited.com/tagit/js/tagit.js" rel="nofollow">http://webspirited.com/tagit/js/tagit.js</a></p> <p>Also here is the INSERTION code, incase it's something I need to look at there</p> <pre><code>$tags = isset($_POST['tags']) ? $_POST['tags'] : null; if (is_array($tags)) { foreach ($tags as $t) { // escape the $t before inserting in DB $sql = "INSERT INTO tags (tags) VALUES('$t')"; } </code></pre> <p>Thanks for any tips</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload