Adding javascript validation using DataUtilities on create wizard
Hi all,
I have a requirement of driver and dependent attributes which is based on selection of one value from combobox other attribute values should get populated. I'm referring to this solution https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS64401.
So I have created a data utilities class which is mapped to my driver attribute. And from that I can able to
call my javascript function which I have added in jsp page.
And that onchange validation also working fine. But my javascript function is not changing the value of other attribute.
Here is my javascript function.
<script type="text/javascript">
function customChangefunction(){
var target = window.document.getElementsByName("resultCombo");
var src = window.document.getElementById("sampleCombo");
var strUser = src.options[src.selectedIndex].value;
alert(strUser);
var colours = new Array('Black', 'White', 'Blue');
var shapes = new Array('Square', 'Circle', 'Triangle');
var names = new Array('John', 'David', 'Sarah');
switch (strUser) {
case 'one':
target.options.length = 0;
for (i = 0; i < colours.length; i++) {
createOption(target, colours[i], colours[i]);
}
break;
case 'two':
target.options.length = 0;
for (i = 0; i < shapes.length; i++) {
createOption(target, shapes[i], shapes[i]);
}
break;
case 'three':
target.options.length = 0;
for (i = 0; i < names.length; i++) {
createOption(target, names[i], names[i]);
}
break;
default:
target.options.length = 0;
break;
}
}
function createOption(ddl, text, value) {
var opt = document.createElement("OPTION");
opt.value = value;
opt.text = text;
ddl.options.add(opt);
opt.appendChild(text);
document.getElementById(ddl).appendChild(opt);
}
</script>
Can some tell me this is the correct way of doing it. And why this js function not working? From onchange I'm getting
the selected value.
And I have one more doubt if my dependent attribute is already having some values will this override and populate what we give here?
Please suggest me some solution.

