سؤال

I want to allow the user to select multiple options for one metadata,and we need to provide check boxes for the same.I have modified the respective include and added the java script ,but some how the value is not getting assigned to the metadata: I have modified the include and added JS as follows ,but the metadata is not getting assigned the selected values,can any one tell me where am I going wrong:

     <script type="text/javascript">
           function getSelected(Language) {
                                       var selected = new Array();
                                       var index = 0; for (var intLoop=0; intLoop < Language.length; intLoop++) {
                                       if (Language[intLoop].selected) {             index = selected.length;        
                                                                       selected[index] = new Object;    
                                                                       selected[index].value = Language[intLoop].value;          
                                                                        selected[index].index = intLoop;         }      }      
                                                                            return selected;
                                                                           }
function submit(selected)
{
var value =selected;
xTranslateTo = value;
}
</script>
<$if strEquals(fieldName, "xTranslateTo") and not (isInfo or isQuery)$>
<tr <$strTrimWs(inc("std_nameentry_row_attributes"))$>>
<td <$if captionFieldWidth$>width="<$captionFieldWidth$>"<$endif$> <$if isInfo$>align=right<$endif$>><$strTrimWs(inc(fieldCaptionInclude))$></td>
<td <$if isFieldInfoOnly$>colspan="100"<$endif$> <$if captionEntryWidth$>;width="<$captionEntryWidth$>"<$endif$>><$inc(fieldEntryInclude)$>

<INPUT TYPE=CHECKBOX  NAME="Language" VALUE="English">English
<INPUT TYPE=CHECKBOX  NAME="Language" VALUE="Italian">Italian
<INPUT TYPE=CHECKBOX  NAME="Language" VALUE="French">French
<INPUT TYPE=CHECKBOX  NAME="Language" VALUE="German" >German</td>
</tr>
 <a href="javascript:;" onclick=" getSelected()">
<$else$>
<$include super.std_nameentry_row$>
<$endif$>

Can any one throw some light on where am I going wrong

هل كانت مفيدة؟

المحلول 2

I'm able to display check boxes and assign comma separated value to the metadata,now all i'm left to do is to display the checked boxes when the user calls for update metadata form.

<$if strEquals(fieldName, "xLang") and not (isInfo or isQuery)$>
<script>
function boxFunc()
{
    var textval=document.getElementsByName('xLang')[0];
        var langs=document.getElementsByName("ucmlang");
        larray="";
            for(i=0;i<langs.length;i++)
          {
             if(langs[i].checked)
                   {
                     larray=larray+langs[i].id+",";
                   }
      }
           larray=larray.substring(0,larray.length-1);
          textval.value=larray;

}
</script>
<tr <$strTrimWs(inc("std_nameentry_row_attributes"))$>>
<td<$if captionFieldWidth$>width="<$captionFieldWidth$>"<$endif$> <$if isInfo$>align=right<$endif$>><$strTrimWs(inc(fieldCaptionInclude))$></td>
<td <$if isFieldInfoOnly$>colspan="100"<$endif$> <$if captionEntryWidth$>;width="<$captionEntryWidth$>"<$endif$>><$inc(fieldEntryInclude)$></td>
<td><!– addition –>English<!– end addition –><input type="checkbox"  name="ucmlang"  id = "English" onclick="boxFunc()">
<td><!– addition –>French<!– end addition –><input type="checkbox"  name="ucmlang"  id = "French" onclick="boxFunc()"></td>
<td><!– addition –>Italian<!– end addition –><input type="checkbox"  name="ucmlang"  id = "Italian" onclick="boxFunc()"></td>
<td><!– addition –>German<!– end addition –><input type="checkbox"  name="ucmlang"  id = "German" onclick="boxFunc()"></td>
<td><!– addition –>Japanese<!– end addition –><input type="checkbox"  name="ucmlang"  id = "Japanese" onclick="boxFunc()"></td>
</tr>
<$else$>
<$include super.std_nameentry_row$>
<$endif$>

نصائح أخرى

I suppose your problem is this line:

xTranslateTo = value;

IDOC is running on server side, hence all metadata variables are not accessible in JS on client side. Right now your script is just setting value of the local JS variable with name 'xTranslateTo', nothing else.

You need to create hidden field 'xTranslateTo' and populate it in your JS instead of this local variable. Once this hidden field is sent during submit it will be parsed on the server side and put to the corresponding metafield.

Of course it will also require an additional parsing on IDOC for setting previously selected languages' checkboxes.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top