Copy link to clipboard
Copied
Okay, so I have a dropdown box (SName) and I have a textbox (Sender_Name). This is what I need to do. I need the dropdown box if anything is selected other than other the value of Sender_Name = the value of SName. Otherwise if other is selected from the dropdown then the textbox becomes visible and the value is the default value. However this is where I am having an issue. I need that value to change if the user enters text in (which I have working) but when you enter off the dropdown (SName) the commitKey for enter doesn't seem to be working. Tab and clicking off works correctly but enter is not. Any help is greatly appreciated. Thank you.
This portion of Javascript was put in the onBlur (run javascript) section of my dropdown field (SName):
var Name = this.getField('Sender_Name');
var SN = this.getField('SName');if (((event.commitKey = 1) && (SN.value == "Other")&&(Name.value != Name.defaultValue)) || ((event.commitKey = 2) && (SN.value == "Other")&&(Name.value != Name.defaultValue)) || ((event.commitKey = 3) && (SN.value == "Other")&&(Name.value != Name.defaultValue))){
Name.value = "Please Enter a Sender Name";
}
This portion of Javascript was put in my format javascript for my dropdown field (SName):
var Name = this.getField('Sender_Name');
var SN = this.getField('SName');if (SN.value=="Other") {
Name.display = display.visible;
}
else{
Name.value = SN.value;
Name.display = display.noView;
}
This protion of Javascript was put in the onFocus (run javascript) section of my textbox (Sender_Name):
if(event.target.value=="Please Enter a Sender Name"){
event.target.value ="";
}
This portion of Javascript was put in my format section of my textbox (Sender_Name):
function sname(){
if (!event.willCommit) {
var value = AFMergeChange(event);
if(!value) return;
if(!AFExactMatch(/^[a-zA-Z \ ]{0,38}/, value)) event.rc = false;
}
}
and obviously calling the keystroke in my textbox (Sender_Name):
sname();
Got it working the way I need it to be.
function checkSenderName() {
if (!event.willCommit) return;
var Name = this.getField('Sender_Name');
if (event.value == "Other") {
Name.value = "Please Enter a Sender Name";
Name.display = display.visible;
Name.setFocus();
} else {
Name.value = event.value;
Name.display = display.noView;
}
}
Copy link to clipboard
Copied
This is wrong:
event.commitKey = 1
It should be:
event.commitKey == 1
Copy link to clipboard
Copied
I just changed the event.comitKeys to == but now it isn't working at all...
Copy link to clipboard
Copied
Anyone available to assist me with this issue? Please and thank you.
Copy link to clipboard
Copied
Got it working the way I need it to be.
function checkSenderName() {
if (!event.willCommit) return;
var Name = this.getField('Sender_Name');
if (event.value == "Other") {
Name.value = "Please Enter a Sender Name";
Name.display = display.visible;
Name.setFocus();
} else {
Name.value = event.value;
Name.display = display.noView;
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now