Isaac
asked on
jquery onchange function problem
In the jsfiddle is code that creates a copy of html elements. It works fine but duplicates. How can I prevent it from duplicating? What do I test for?
Also, the following line never gets executed?
http://jsfiddle.net/isogunro/t28sv760/13/
Also, the following line never gets executed?
$("#tabs").prepend("<ul id='tabIndex'><li>"+copyFilterBy+"</li></ul>");
http://jsfiddle.net/isogunro/t28sv760/13/
ASKER
Yes, I would like to prevent it from duplicating, if possible. I know, sounds crazy.
Check out the onchange
http://jsfiddle.net/isogunro/t28sv760/13/
Check out the onchange
http://jsfiddle.net/isogunro/t28sv760/13/
So what to you want to show up in #tabs div if not a copy of .controlGroup? Do you want just the text inside the select options to show up as list items?
ASKER
Yes, text inside the select options.
As I toggle back an forth, is there a way to remove what I duplicated before I add it again when the drop down is "Punctuality"?
As I toggle back an forth, is there a way to remove what I duplicated before I add it again when the drop down is "Punctuality"?
Something like this might get you closer based upon you wanting to remove what you duplicated before you add it again when the drop down is "Punctuality".
$("#DashboardToggle select").change(function()
{
alert("HEllo Dashboard");
var val = $(this).find("option:selec ted").val( );
if(val == "GLChart")
{
alert("Show GLChart");
}
if(val == "Punctuality")
{
alert("Show Punctuality");
var copyFilterBy = $(".controlGroup").clone() ;
$(copyFilterBy).appendTo(" body");
$(".controlGroup" ).first().remove();
}
});
alert("outside");
$("#tabs").prepend("<ul id='tabIndex'><li>"+copyFi lterBy+"</ li></ul>") ;
$("#DashboardToggle select").change(function()
{
alert("HEllo Dashboard");
var val = $(this).find("option:selec
if(val == "GLChart")
{
alert("Show GLChart");
}
if(val == "Punctuality")
{
alert("Show Punctuality");
var copyFilterBy = $(".controlGroup").clone()
$(copyFilterBy).appendTo("
$(".controlGroup" ).first().remove();
}
});
alert("outside");
$("#tabs").prepend("<ul id='tabIndex'><li>"+copyFi
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This works for me. I have another similar question that I will post in a few minutes.
Thnaks
Thnaks