I’m trying to allow users to input multiple id #’s separated by commas in an input field. I want to then take that input, separate the data by comma’s and insert them into separate <li> tags to display in another div, (for verification purposes), prior to submitting. Here is what I have so far…please be gentle…I’ve not had to do this before.
if ($("#" + prodID).find("input.text").val() == value) {
$("#" + prodID).find("input.text").val("");
}
This is where I am so far and don’t know where to go from there. I believe that I will need to add replaceWith() to the end of .val(""); but am not sure. If there are examples I can look at I’m sure I can figure this out.
Any assistance is greatly appreciated.
Here is the HTML. (sorry I missed it at first)
<div id="selCodes">
<p>Your selected codes <span><a href="#">Clear</a></span></p>
<ul>
<li><!--inserted by clicking "okay"-->
Some Account - 0123<a href="#" title="delete"><img alt="delete" src="imgs/delete.png"></a>
</li>
</ul>
<button id="subCodes">Submit</button>
</div><!-- /#my-selections -->
<h4>Narrow results by</h4>
<div id="prodId">
<a href="#">Item code</a>
<span><a href="#">Clear</a></span>
<p>Choose item from dropdown. Type code or codes, (separated by comma), and click the add button to create filters.</p>
<select id="code-type">
<option>Prod code</option>
<option selected="selected">Prod UPC</option>
<option>Master UPC</option>
<option>CC</option>
</select>
<input type="text" value="" />
<button>OK</button>
</div>
I have a funny feeling I’m way off-base.
Here’s the DEMO
Here’s the code:
I used your html in my demo, with a slight modification of adding an id on the input box and adding a validation result div at the bottom.