Home › Forums › General Issues › Input field and a button, can i make a field type like this? › Reply To: Input field and a button, can i make a field type like this?
Here’s a detailed suggestion on how to approach your scenario.
Firstly, you’ll need to create an input field on your webpage where users can enter a YouTube video ID. This input field can be either a text box or a drop-down list, depending on how you want your users to enter the data.
Next, add a button next to the input field labeled “Fetch Video Details” or something similar. On clicking this button, it should trigger a JavaScript function that will fetch the details of the YouTube video using the entered video ID.
To do this, you can use the YouTube Data API, which allows you to retrieve information about YouTube videos, channels, and playlists. You’ll need to first authenticate your API requests using an API key and then make a GET request to the API endpoint, passing the video ID as a parameter.
After receiving the data from the API, you can parse the JSON response and populate the relevant fields on your webpage with the received data. These fields can be title, description, view count, likes, dislikes, etc. which are available in the API response.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.