-
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 ago by Satyakam.
- This discussion was modified 8 years ago by Satyakam.
- This discussion was modified 8 years ago by Satyakam.
- This discussion was modified 8 years ago by Forcetalks.
- This discussion was modified 8 years ago by Forcetalks.
- This discussion was modified 8 years ago by Forcetalks.
- This discussion was modified 8 years ago by Forcetalks.
- This discussion was modified 8 years ago by Forcetalks.
- This discussion was modified 8 years ago by Forcetalks.
- This discussion was modified 8 years ago by Forcetalks.
- This discussion was modified 8 years ago by Forcetalks.
- This discussion was modified 6 years, 5 months ago by Forcetalks.
Log In to reply.
Popular Salesforce Blogs
Salesforce Mobility & Security – When the user’s PIN is simply not enough
Many of us love and prefer using Salesforce and working with Salesforce data in remote locations, on mobile devices. With an ever-increasing popularity and high-speed…
What is the Flosum Tool in Salesforce in 2023?
Version control, continuous deployments, static code analysis, in-built merge tools, user story management, and continuous testing are all features of the native tool Flosum in…
Enabling and Creating Personal Accounts And Business Accounts in Salesforce
Salesforce accounts are used to store information about customer and entities with which you are working such as government agencies, schools, companies, or individuals. You…
Popular Salesforce Videos
Salesforce CPQ: Fixing Percent of Total Calculations for Amended Quotes
Salesforce users looking to enhance their product-quoting processes can take advantage of Salesforce Configure, Price, Quote Software, or CPQ. Some features require the use of…
Salesforce Marketing Cloud Automation Studio
Automation Studio is a Marketing Cloud application used to execute multi-step marketing and data management activities on an immediate, triggered, or scheduled basis. Use Automation…