Note that there are some explanatory texts on larger screens.

plurals
  1. POtroublesome javascript
    primarykey
    data
    text
    <p>I'm trying to make a little tag list doohickey for adding and removing tags. I have a textbox where the user can enter the tags, separated by commas. and an add button. I would like it for when the user clicks the add button to add a small div to the inside of a div below the box. the small div should contain the tag and a little x for which to remove the tag later. heres what I have:</p> <pre><code>&lt;script type='text/javascript'&gt; function tagsremove(tag) { document.getElementByName('tags').value.replace('/'+tag+'\,\s/', ''); } $('#tagbutton').click(function(){ var tags = $('#tagsbox').text().split(", "); for (var tag in tags) { document.getElementByName('tags').value += tag +", "; $('#curtags').append("&lt;div class='tag'&gt;" + tag + " &lt;a href='#' onlclick='tagsremove(\'" + tag + "\');$(this).hide();'&gt;x&lt;/a&gt;&lt;/div&gt;") } }); &lt;/script&gt; &lt;div class='statbox'&gt; &lt;form method='post' action='post.php' id='writeform'&gt; &lt;p class='subtitle'&gt;Title&lt;/p&gt; &lt;input type='text' name='title' id='titlebox' /&gt;&lt;br /&gt; &lt;p class='subtitle'&gt;Body&lt;/p&gt; &lt;textarea id='postbox' name='body' rows='10'&gt;&lt;/textarea&gt;&lt;br /&gt; &lt;p class='subtitle'&gt;Tags&lt;/p&gt; &lt;input type='text' id='tagsbox' /&gt;&lt;input type='button' id='tagbutton' value='Add' /&gt; &lt;p class='subsubtitle'&gt;Seperate by commas (eg. "programming, work, job")&lt;/p&gt; &lt;div class='subsubtitle' id='curtags'&gt;Current Tags:&lt;/div&gt; &lt;input type='hidden' value='' name='tags' /&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>The problem i'm having is that when I click the add button, nothing happens. I would like to fix this.</p>
    singulars
    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