Support

Account

Home Forums General Issues Select Dropdown Inside Repeater With Mailto and Tel based on Selection

Solving

Select Dropdown Inside Repeater With Mailto and Tel based on Selection

  • Trying to setup inside my Repeater a way for me to select either EMAIL ADDRESS or PHONE NUMBER.

    – if i select EMAIL ADDRESS, it would populate the ‘mailto:’ before the email subfield where i’d enter the email

    – if i select PHONE NUMBER, it would populate the ‘tel:’ before the phone number that’s entered into the field

    is there a way to do this with an if else using one field for the email/phone

    if i entered in the subfield: [email protected] or 333-333-4444, it could then know based on the dropdown selection whether to add mailto: or tel: before that field?

  • Do you need this to change on the backend or frontend? For the backend, you can change the prefix of a field using a filter. On the frontend, a regex to the field can determine whether to use mailto: or tel:.

  • @andisaleh

    Thanks for the response — see below with image and php that helps explain


    IMAGE EXPLAINATION:

    https://pasteboard.co/5fFEy9KEfp0o.jpg

    PHP CODE:
    PHP CODE HERE: https://onlinephp.io/c/ea1db

    -user goes to WP Page
    ->Adds Image, Title, etc
    -Select Dropdown – choice of PHONE or EMAIL

    If user Selects PHONE, it populates tel: before the subfield they enter of a phone number so it makes it a link

    If user Selects EMAIL, it populates mailto: before the subfield they enter of a phone number so it makes it a link

  • 
    if (get_field('select_field_name') == 'EMAIL ADDRESS') {
      echo 'mailto:';
    } else {
      echo 'tel:';
    }
    
  • @andisaleh

    See image and php code below but essentially:

    -user goes to WP Page
    -Adds Image, Title, etc
    -Select Dropdown – choice of PHONE or EMAIL

    If user Selects PHONE, it populates tel: before the subfield they enter of a phone number so it makes it a link

    If user Selects EMAIL, it populates mailto: before the subfield they enter of a phone number so it makes it a link

    Image Explanation: https://pasteboard.co/5fFEy9KEfp0o.jpg
    Code Sandbox: : https://onlinephp.io/c/ea1db

    in the php code – its in the div “phoneemail-selection” towards bottom where id imagine the IF / ELSE statement would go:

  • @andisaleh

    See image and php code below but essentially:

    -user goes to WP Page
    -Adds Image, Title, etc
    -Select Dropdown – choice of PHONE or EMAIL

    If user Selects PHONE, it populates tel: before the subfield they enter of a phone number so it makes it a link

    If user Selects EMAIL, it populates mailto: before the subfield they enter of a phone number so it makes it a link

    ————

    Image Explanation: https://pasteboard.co/5fFEy9KEfp0o.jpg
    Code Sandbox: : https://onlinephp.io/c/ea1db

    in the php code – its in the div “phoneemail-selection” towards bottom where id imagine the IF / ELSE statement would go:

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.