Copy link to clipboard
Copied
Hi
I have a dropdown(combobox) Field named Doctor, where upon selection, Phone and Address Field will auto populate.
But when a user inputs that is not part of the dropdown list, the user can still write values on the Phone and Address Field. My code right now clears the phone and address field when user inputs value on the Doctor Field (dropdown, combobox)
Another case is, when a user accidentally selects an item from the dropdown, but wanted to input value not on the list. I'd like to clear the phone and address field, then allow user to input another values.
Thank You
if(event.value==""){
this.getField("Phone").value="";
this.getField("Address").value="";
}
else if(event.value=="A"){
this.getField("Phone").value = "PhoneA";
this.getField("Address").value = "AddressA";
}
else if(event.value=="b"){
this.getField("Phone").value = "PhoneC";
this.getField("Address").value = "AddressC";
}
else{
this.getField("Phone").value="";
this.getField("Address").value=""
}
Move the code in the Doctor field as Custom Keystroke script.
You csn do something like :
if(event.willCommit && ( event.value !== "")) {
this.getField("Phone").value ="";
this.getField("Address").value ="";
} else {
if (event.value == "A") {
this.getField("Phone").value ="Phone A";
this.getField("Address").value = "Address A";
}
if (event.value == "B") {
this.getField("Phone").value ="Phone C";
this.getField("Address").value ="Address C";
}
}
Copy link to clipboard
Copied
Use script as 'Validation'.
Copy link to clipboard
Copied
Move the code in the Doctor field as Custom Keystroke script.
You csn do something like :
if(event.willCommit && ( event.value !== "")) {
this.getField("Phone").value ="";
this.getField("Address").value ="";
} else {
if (event.value == "A") {
this.getField("Phone").value ="Phone A";
this.getField("Address").value = "Address A";
}
if (event.value == "B") {
this.getField("Phone").value ="Phone C";
this.getField("Address").value ="Address C";
}
}
Copy link to clipboard
Copied
Thanks. I didn't take about custom keystroke, this works well .
Copy link to clipboard
Copied
I modified the code a bit that works better for me. After checking that Doctor field is not empty, then it would check if event values are matching with any drop downs. If it doesn't match any drop downs, after commit it would erase the phone and address field.
if(event.willCommit && ( event.value == "")) {
this.getField("Phone").value ="";
this.getField("Address").value ="";
} else {
if (event.value == "A") {
this.getField("Phone").value ="Phone A";
this.getField("Address").value = "Address A";
}
else if (event.value == "B") {
this.getField("Phone").value ="Phone C";
this.getField("Address").value ="Address C";
}
else if(event.willCommit && event.value !="") {
this.getField("Phone").value ="";
this.getField("Address").value ="";
}
}