CMS Development

jesusgonzalez20
Member

change value of input depending of the select option

SOLVE

 

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
sharonlicari
Solution
Community Manager
Community Manager

change value of input depending of the select option

SOLVE

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


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
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

change value of input depending of the select option

SOLVE

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

Anton Bujanowski Signature

View solution in original post

3 Replies 3
Anton
Solution
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

change value of input depending of the select option

SOLVE

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

Anton Bujanowski Signature
jesusgonzalez20
Member

change value of input depending of the select option

SOLVE

Thanks, it works Smiley Happy

sharonlicari
Solution
Community Manager
Community Manager

change value of input depending of the select option

SOLVE

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


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




0 Upvotes