-
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, 10 months ago by
Satyakam.
-
This discussion was modified 8 years, 10 months ago by
Satyakam.
-
This discussion was modified 8 years, 10 months ago by
Satyakam.
-
This discussion was modified 8 years, 10 months ago by
Forcetalks.
-
This discussion was modified 8 years, 10 months ago by
Forcetalks.
-
This discussion was modified 8 years, 10 months ago by
Forcetalks.
-
This discussion was modified 8 years, 10 months ago by
Forcetalks.
-
This discussion was modified 8 years, 10 months ago by
Forcetalks.
-
This discussion was modified 8 years, 10 months ago by
Forcetalks.
-
This discussion was modified 8 years, 10 months ago by
Forcetalks.
-
This discussion was modified 8 years, 10 months ago by
Forcetalks.
-
This discussion was modified 7 years, 3 months ago by
Forcetalks.
-
This discussion was modified 8 years, 10 months ago by
Log In to reply.
Popular Salesforce Blogs
![Salesforce Summer '22 Release](https://images.forcetalks.com/wp-content/uploads/2022/05/12185643/Salesforce-Summer-22-Release.jpg)
Salesforce Summer '22 Release - Go Through the Highlights
Lather on the sunscreen and pour a cold glass of lemonade; warm weather is here, which means it's time for Salesforce's Summer '22 update release!…
![](https://images.forcetalks.com/wp-content/uploads/2019/12/06111501/sa_1575630857SalesforceDataLoss.png)
Salesforce Data Loss: Is Your Data Correct? How Can UI Contribute?
For a number of years security and safety of data has been the major reason which proved itself to be a hiccup in the path…
![](https://images.forcetalks.com/wp-content/uploads/2024/08/01103113/sa_1722508102Salesforce%20Automation%20for%20Small%20Businesses.jpg)
Salesforce Automation for Small Businesses: The Essential Guide
What if you are a successful business owner, and your outstanding salespersons have to waste their time on repetitions? Sound familiar? Small business ownership entails…
Popular Salesforce Videos
Get Together Safely with Salesforce Safety Cloud
Learn how Safety Cloud helps people get together in person, safely. Safety Cloud helps businesses and communities better manage their testing, health and entry protocols…
Why are Salesforce Releases Named After Seasons?
If you are wondering “Why are Salesforce releases named after Northern Hemisphere Seasons?” then get an expert answer by Megan Peterson and Salesforce Co-Founder Parker…
What is the Difference Between Object and Database in Salesforce?
Salesforce Object: Salesforce Object are database table which give permission to store data that is specific to organization. Salesforce Database: The organized collection of object…