-
Add a value in Datalist using Jquery
In a scenario there is a Datalist and there are some Datalist values in that Datalist. When you will click on any Datalist value that value will be invisible from that Datalist and should be shown on vf page with a checkbox and when you will check that checkbox that value will be invisible from page and again should be shown in datalist. I want to solve this problem using JQuery. I have gone through following code but not getting complete solution. Can i get any solution..?
function checkboxClick(obj){
var id = $(obj).attr("id");
if($('#' + id).is(":checked")){
$(obj).closest("tr").remove();
}
}
$(document).ready(function(){
var a;
var idCounter=1;
$(document).on('click', '#ddlList', function () {
a = $('#ddlList option:selected').text();
$('#ddlList option:selected').remove();
if(a != ''){
var b = $('#demo').append('<tr>
<td><input type="checkbox" onclick="checkboxClick(this)" id="ck_'+idCounter+'"/></td>
<td class="newLine">'+a+'</td>
</tr>
');
idCounter++;
}
});
});----------------------
<select id="ddlList">
<option value="0">None</option>
<option value="1">ASP.NET</option>
<option value="2">C#</option>
<option value="3">VB.NET</option>
<option value="4">HTML</option>
<option value="5">jQuery</option>
</select>
<table id="demo">
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>- This discussion was modified 8 years, 7 months ago by Satyakam.
- This discussion was modified 8 years, 7 months ago by Satyakam.
- This discussion was modified 8 years, 7 months ago by Satyakam.
- This discussion was modified 8 years, 7 months ago by Forcetalks.
- This discussion was modified 8 years, 7 months ago by Forcetalks.
- This discussion was modified 8 years, 7 months ago by Forcetalks.
- This discussion was modified 8 years, 7 months ago by Forcetalks.
- This discussion was modified 8 years, 7 months ago by Forcetalks.
- This discussion was modified 8 years, 7 months ago by Forcetalks.
- This discussion was modified 8 years, 7 months ago by Forcetalks.
- This discussion was modified 8 years, 7 months ago by Forcetalks.
- This discussion was modified 7 years ago by Forcetalks.
Log In to reply.
Popular Salesforce Blogs
Salesforce Health Cloud for Dermatology Practice Management
In the ever-evolving landscape of healthcare, technology is critical to enhancing patient care and streamlining practice management. This is particularly true for dermatology practices as…
The Top Reasons to Invest in Salesforce Professional Services
In today's business world, technology is a big deal, and when it comes to making things work better, Salesforce is like the superhero of software.…
Popular Salesforce Videos
Learn DML Statements in Salesforce Development
In this video, We'll be learning about DML (Data Manipulation Language) in Salesforce development: We will be discussing the following things in this video: 1.…
Live Demo of Salesforce Industries
Watch the live demo to have a better understanding of Vlocity i.e Salesforce Industries. Let's have a glance at this extract from our latest webinar!…
Share Visualforce Pages Between Classic and Lightning Experience | Salesforce Trailhead
Visualforce Pages should be created correctly such that they behave properly whether they run in Salesforce Classic or Lightning Experience. Detecting and Responding to the…