Hi again phprunners,
I followed the instructions on how to add custom field on form via here, but instead of text box I made it to dropdown list:
<SELECT
id=test required> <OPTION disabled selected value="">Please
select...</OPTION><OPTION value=foo>Something</OPTION>
<OPTION value=other>Other</OPTION> <OPTION
value=RSA>RSA</OPTION></SELECT>
BTW, I wanted a custom field so I can have access to the .onchange property on javascript. I have this on the add page javascript onload event:
document.getElementById("test").onchange = function () {
var val = this.options[this.selectedIndex].value;
document.getElementById("otherTb").style.display = (val == "other") ? "block" : "none";
document.getElementById("rsatb").style.display = (val == "RSA") ? "block" : "none";
};
this.on('beforeSave', function(formObj, fieldControlsArr, pageObj){
var val = $("#test").val();
formObj.baseParams['test'] = val;
});
So that these (place somewhere in the add form):
<DIV id=otherTb style="DISPLAY: none">Something to show</DIV>
<DIV id=rsatb style="DISPLAY: none"> My Style</DIV>
, will toggle their display depends on the selection.
This are just test codes but I'm stuck on making the dropdown a required field.
Basically the question is how can I make my custom field behave as required field the same way as the other required fields behave in the add form?
Now, am I doing this the hard way or is there another way to accomplish this without making the dropdown a custom field?
Please help I've been testing codes for about 6 hours. Thanks in advance.