ndh ndh - 3 months ago 10
HTML Question

How to change a field type in netsuite?

I am trying to create an online form using Netsuite.

We have a set for predefined fields like firstname, lastname, etc.

In the same we have a


NLSUBSCRIPTIONS


tag but the field type by default is drop down with multiple select option.

How can I change this drop down to a checkbox?

Answer

If you use a custom template you can hide the drop-down and iterate its options to create your own checkboxes.

e.g.

    <div class="regFieldWrap">
        <span class='cbExpand hideNsLabel'><NLCUSTENTITY_LIST_FIELD></span><input class="otherShadow valid" type="text" name="custentity_list_field_other"><span class="multiProto cbHolder"><input type="radio" name="custentity_list_field"><label class="cbLabel"></label></span>
    </div>

and then

<script>
jQuery(function($){
        // convert multi select to checkbox
        $("span.multiProto").each(function(){
            var proto = this;
            var selName = $(proto).find("input").attr("name");
            var otherCB = null;
            $("select[name='"+selName+"']").css({display:'none'}).each(function(){
                var sel = $(this);
                var isReq = sel.hasClass('inputreq');
                if(isReq) sel.removeClass('inputreq');
                sel.find("option").each(function(){
                    if(!this.value) return;
                    var newby = $(proto.cloneNode(true));
                    var cb = newby.find("input").val(this.value);
                    if(isReq) cb.addClass('cb_selectone');
                    newby.find("label.cbLabel").text(this.text);
                    $(newby).removeClass('multiProto');
                    if((/\bother\b/i).test(this.text)){
                            var otherField = $("input.otherShadow[name='"+ selName+"_other']").each(function(){
                                var newOther = this.cloneNode(true); // strange but it gets around an IE issue
                                $(this).remove();
                                $(newby).find("input").data("conditionalOther", newOther);
                                newby.get(0).appendChild(newOther);
                            });
                            otherCB = newby;
                    } else proto.parentNode.insertBefore(newby.get(0), proto);
                });
                sel.get(0).options.length = 0;
            });
            if(otherCB) proto.parentNode.insertBefore(otherCB.get(0), proto); // make sure this is the end element
        });

});