Multi-Picklist to Check boxes default selecting the first value

Anonymous
Not applicable

Multi-Picklist to Check boxes default selecting the first value

I have a form that has multi-select fields that I converted to multi-select checkboxes on the landing page using the java scripts shown in one of the Marketo Masters tutorials.  I know the fields are not set to have a default value in SFDC, and I can't find anything on the form that I can change that tells it to have a default value, but it is automatically selecting the first checkbox listed for each question that has this multi-select checkbox format.  

Does anyone know how I can stop this from happening?  I don't want any of the boxes to be checked when prospects come to this page.


Tags (1)
4 REPLIES 4
Anonymous
Not applicable

Re: Multi-Picklist to Check boxes default selecting the first value

Can you show us the code?
Anonymous
Not applicable

Re: Multi-Picklist to Check boxes default selecting the first value

Here is the code.

<script language="JavaScript" src="/js/public/jquery-latest.min.js" type="text/javascript"></script>
<script type="text/javascript" language="JavaScript">
$jQ = jQuery.noConflict();
$jQ(document).ready(function(){
// replace all multi-select boxes with checkboxes
$jQ("select[multiple]").each(function(){
// firstwrap a div around it
$jQ(this).wrap("<div class='selectWrap'></div>");
 
// loop over the option tags, add checkboxes for each
$jQ(this).children("option").each(function(){ 
var curVal = $jQ(this).attr("value");
var curText = $jQ(this).text();
 
//if its selected prep the checked for the insert
if($jQ(this).is(":selected")) {
var curStatus = "checked='checked'";
} else {
var curStatus = "";
}
 
// if the current value isn't empty,
// insert the checkbox and label
// (uses for='' to make the text clickable)
if(typeof curVal != "undefined") { 
 
 
var curCheckInsert = "<br /><label for='" + 
 
curVal + "Check'>" + curText + "</label><input type='checkbox' id='" + 
curVal + "Check' " + curStatus + 
" value='" + curVal + "' />"; 
}
 
// add the checkbox to the new div
$jQ(this).parents("div.selectWrap").append(curCheckInsert);
});
 
//hide the original select box
$jQ(this).addClass("hidden").hide();
});
 
//add click handler to the new checkboxes
$jQ("div.selectWrap input[type=checkbox]").click(function () { 
 
//Get the value to match with the selectbox
var checkVal = $jQ(this).attr("value"); 
 
//if checked, find the sibling select with the same value and make it selected
//otherwise, remove the selected attribute
if($jQ(this).is(":checked")) { 
$jQ(this).siblings("select").children("option[value=" + checkVal + "]").attr("selected","selected");
} else { 
$jQ(this).siblings("select").children("option[value=" + checkVal + "]").removeAttr("selected");
}
});
 
});
</script>
Anonymous
Not applicable

Re: Multi-Picklist to Check boxes default selecting the first value

Yea, i can see where the code should be modified to make them all unchecked, but it's monday morning at 8am and I feel like I got hit by a truck. So instead I wonder if you could go to the landing page, on the top right go to form settings, and uncheck pre-fill. See if that does what you want it to, first, and if not we can look at modifying the code. 
Anonymous
Not applicable

Re: Multi-Picklist to Check boxes default selecting the first value

Unfortunately, unchecking the pre-fill box didn't work.  😞