dynamic creation of checkbox

SnowDEV2
Kilo Expert

Hi,

I want some value to be fetched from a table & display them as check-box in a catalog item.

Thanks in advance

27 REPLIES 27

how are you displaying the selected categories in request item ?



as far as I know , they are not saved in ui pages after submit.


Yes, you are right. This is custom HTML and not getting saved after submit. We are using an onSubmit client script to get values from all selected checkboxes and then storing the comma separated   string of those values to some other hidden variable. To represent these values on RITM form , we are adding selected categories to description variable. Here you need the class name of the checkbox input to get all checboxes in an array.


Code in an onSubmit Script



var values = '' ;


  var allValues = document.getElementsByClassName('check') ;                           // check is the classname of input HTML field of type checkbox


  for(var i = 0; i < allValues.length ; i++ ){                     //traversing over all checkboxes


  if (allValues[i].checked){                                                                     //getting only checked checkboxes


  values += ','+ allValues[i].value ;


  }


}


values = values.substring(1) ;



//here values is a comma separated string of all selected checboxes and you could store it in any other variable or may add to description.


Hi Gurpreet, I used your examples to create a UI page that generates checkboxes dynamically.



Now, I need to be able to take the SELECTED values and create a new custom task record.



How can I grab the selected values from the UI page? I know you said to use an onSubmit script, but I am not sure where to place it and how to grab the selected values from the UI page.



Thank you!


Hi Kda617,



Call a function onSubmit of your form and then write the same code in that function to populate these values in another hidden input field.


Hi Gurpreet,


I was wondering if you know how to link a client script to a UI Macro?   I have used your solution above...Awesome by the way!, and I am putting the HTML piece on the UI Page inside the XML area of a UI Macro and using it in a Macro Variable.   This very nicely displays the box that holds the checkboxes created by the client script portion of the UI Page.   I am wanting to use the client script and have it put those checkboxes into this box in the UI Macro.   Any thoughts or examples to do this?



Thanks,


Trena