Skip to main content
Inspiring
September 30, 2024
Answered

Extention email

  • September 30, 2024
  • 2 replies
  • 1017 views

Dear all 

After Greetings,

I have drop-down list of extension email

I need javae script when I choose one of them add automatic to field of email

Such as for example 

When I choose @8395988 from drop down list 

 add automatic to felid of email to be like that

 

Name of field drop down list : drop down

Name of field email : email

This topic has been closed for replies.
Correct answer Nesa Nurani

Use this as custom calculation script of "email" field:

var drop = this.getField("drop down").valueAsString;
if (event.value) {
 var atPos = event.value.indexOf('@');

 if (atPos !== -1) {
  event.value = event.value.substring(0, atPos);}
  event.value = event.value + drop;}

2 replies

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
October 1, 2024

Use this as custom calculation script of "email" field:

var drop = this.getField("drop down").valueAsString;
if (event.value) {
 var atPos = event.value.indexOf('@');

 if (atPos !== -1) {
  event.value = event.value.substring(0, atPos);}
  event.value = event.value + drop;}
ali_3480Author
Inspiring
October 1, 2024

Wowww

It is Working 

Many Thanks nesa

try67
Community Expert
Community Expert
September 30, 2024

Do you want the actual value of the email field to change, or just how it is formatted?

If the former, then if the user selects one option, and then changes their mind, it will add both domains to the field ("john@gmail.com@yahoo.com"), unless you use code to remove the first selection from the value before applying the new selection.

ali_3480Author
Inspiring
September 30, 2024

Dear 

When write John at field

And I choose from drop down list @8395988

I need It will written automatically John@gmail.com