change value of input depending of the select option

SOLVE
jesusgonzalez20
Member

 

hbspt.forms.create({
          portalId: "ID",
          formId: "IDFORM",
          css: '',
          submitButtonClass: 'botonformu',
          cssClass: 'probandoformu',
          onFormReady: function onFormReady($form, ctx) {
            var pais =  document.getElementById('idselect');
            var telf = document.getElementById('idinputphone');
            
            //$('select[name="probandochange"] > option[value="+52"]').prop("selected", "selected").change();
           // $('input[name="phone"]').val('+52').change();
            

            pais.onchange = function(e) {
		          telf.val = this.val;
              console.log( telf.value = this.value);
            }

  }
        });

Hi everybody.

I'm trying to create a form where change of the value of input(phone) depending of the select option. In another words, for example if the user choose the country Mexico, the input show the lada of that country and and so on and so on.

Something like that?

https://jsfiddle.net/em2wjhqh/4/

can anybody help me?

 

2 Accepted solutions

Accepted Solutions
sharonlicari
Solution
Community Manager

Hey @jesusgonzalez20 

 

Thanks for reaching out! I want to tag in some subject matter experts to get their insight on this situation.

 

@dennisedson @Anton @Jsum  do you have any suggestions for @jesusgonzalez20 ?

 

Thanks,

Sharon


¿Sabías que la Comunidad está disponible en Español?
¡Participa hoy en conversaciones en el idioma de tu preferencia,cambiando el idioma en tus configuraciones!

Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !


View solution in original post

0 Upvotes
Anton
Solution
Key Advisor | Diamond Partner

Hi @jesusgonzalez20

it's easier than you think 🙂 

 

If you'll add a phone number field to the form you'll have a checkbox for "show country code dropdown". Check it and it will automaticly set everything up

 

Bildschirmfoto 2020-05-02 um 13.06.51.png

 

 

Hope this helps

 

 

best, 

Anton




check
Did my post help answer your query? Help the Community by marking it as a solution



View solution in original post

3 Replies 3
sharonlicari
Solution
Community Manager

Hey @jesusgonzalez20 

 

Thanks for reaching out! I want to tag in some subject matter experts to get their insight on this situation.

 

@dennisedson @Anton @Jsum  do you have any suggestions for @jesusgonzalez20 ?

 

Thanks,

Sharon


¿Sabías que la Comunidad está disponible en Español?
¡Participa hoy en conversaciones en el idioma de tu preferencia,cambiando el idioma en tus configuraciones!

Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !


View solution in original post

0 Upvotes
Anton
Solution
Key Advisor | Diamond Partner

Hi @jesusgonzalez20

it's easier than you think 🙂 

 

If you'll add a phone number field to the form you'll have a checkbox for "show country code dropdown". Check it and it will automaticly set everything up

 

Bildschirmfoto 2020-05-02 um 13.06.51.png

 

 

Hope this helps

 

 

best, 

Anton




check
Did my post help answer your query? Help the Community by marking it as a solution



View solution in original post

jesusgonzalez20
Member

Thanks, it works Smiley Happy