Use output from "form" in HTML in an API link

SteepAtticStairs

I have been working on a very simple YouTube Downloader on my GitHub website based off of the loader.to api. This is what I have so far:

<!DOCTYPE html>
<html>
    <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    </head>
    <body>

    <p>
        <form>
            <label for="theurl">Youtube URL:</label><br>
            <input type="text" id="theurl" name="theurl"><br>
            <input type="submit" value="Ok">
        </form>
    </p>

        <iframe 
            style="width:800px;height:250px;border:0;overflow:hidden;" 
            scrolling="no" src="https://loader.to/api/card/?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ">
        </iframe>
        
        <p><a href="https://replit.com/@Pufferfishe/YoutubeDownloader">replit code</a></p>
        <p><a href="https://youtubedownloader.pufferfishe.repl.co">replit website</a></p>
    </body>
</html>

This essentially a webpage that displays a form box with a submit button, and then a pre-defined loader.to block, that only links to one download (in this case, Never Gonna Give You Up). How could I make it so that the YouTube url that you enter into the form box would generate the relevant loader.to card?

cam

Using JavaScript you can:

  • Listen for the "submit" event on the form
  • Stop the form from refreshing the page
  • Get the YouTube URL from the input
  • Set the "src" attribute on the iframe using the YouTube URL

See below for working example.

// Listen for the "submit" event on the form
document.querySelector('form').addEventListener('submit', event => {

  // Stop the form from refreshing the page
  event.preventDefault() 
  
  // Get the YouTube URL from the input
  const youtubeUrl = document.querySelector('[name="theurl"]').value
  
  // Set the "src" attribute on the iframe using the YouTube URL
  document.querySelector('iframe').setAttribute('src', 'https://loader.to/api/card/?url=' + youtubeUrl)
})
        <form>
            <label for="theurl">Youtube URL:</label><br>
            <input type="text" id="theurl" name="theurl"><br>
            <input type="submit" value="Ok">
        </form>

        <iframe 
            style="width:800px;height:250px;border:0;overflow:hidden;" 
            scrolling="no" src="https://loader.to/api/card/?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ">
        </iframe>
        
        <p><a href="https://replit.com/@Pufferfishe/YoutubeDownloader">replit code</a></p>
        <p><a href="https://youtubedownloader.pufferfishe.repl.co">replit website</a></p>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to use html form to submit API link to get JSON response

From Dev

Link from Form HTML/JS

From Dev

Generating HTML Link From Given Values in Form

From Dev

how to link html form input to javascript function and showing the output

From Dev

Output HTML Form Element From Javascript

From Dev

PHP output from HTML input Form

From Dev

How to use fields_for to link multiple models from one form?

From Dev

How to open link fetched from google spreadsheet to a html form button

From Dev

How to extract a link from <form action= in html with jsoup

From Dev

Calling a PHP API from HTML Form?

From Dev

nested xml output from html form using php

From Dev

Unexpected output from html form input DOM reference

From Dev

create html file from form output parsed by php script

From Dev

Output Data From MYSQL Table Into HTML Form Depending On User Choice

From Dev

Output images from a form

From Dev

HTML form to ask email address then use javascript to spit it back out into html page as a link

From Dev

Passing value from HTML link to use in php if statement on next page

From Dev

Add a Spotify link in an HTML form

From Dev

Use output from axios API in one function and pass to another

From Dev

Convert JSON output from API to list of HTML links

From PHP

PHP Array extract or pull everything from the API JSON for html output

From Dev

How to output a String into an HTML document page from a native Function API

From Dev

How to escape HTML,JS,PHP code from api output php?

From Dev

Modify Html form submit output

From Dev

Output HTML form to .txt file

From Dev

Karate API Testing - How to use a variable (output from response) from API 1 to another API in same feature

From Dev

How to extract an embedded link from an as text saved html document OR how to use xidel to extract the correct link?

From Dev

Use data from sql table in a html form with php

From Dev

How to get the value from html form and use it in views.py?

Related Related

  1. 1

    How to use html form to submit API link to get JSON response

  2. 2

    Link from Form HTML/JS

  3. 3

    Generating HTML Link From Given Values in Form

  4. 4

    how to link html form input to javascript function and showing the output

  5. 5

    Output HTML Form Element From Javascript

  6. 6

    PHP output from HTML input Form

  7. 7

    How to use fields_for to link multiple models from one form?

  8. 8

    How to open link fetched from google spreadsheet to a html form button

  9. 9

    How to extract a link from <form action= in html with jsoup

  10. 10

    Calling a PHP API from HTML Form?

  11. 11

    nested xml output from html form using php

  12. 12

    Unexpected output from html form input DOM reference

  13. 13

    create html file from form output parsed by php script

  14. 14

    Output Data From MYSQL Table Into HTML Form Depending On User Choice

  15. 15

    Output images from a form

  16. 16

    HTML form to ask email address then use javascript to spit it back out into html page as a link

  17. 17

    Passing value from HTML link to use in php if statement on next page

  18. 18

    Add a Spotify link in an HTML form

  19. 19

    Use output from axios API in one function and pass to another

  20. 20

    Convert JSON output from API to list of HTML links

  21. 21

    PHP Array extract or pull everything from the API JSON for html output

  22. 22

    How to output a String into an HTML document page from a native Function API

  23. 23

    How to escape HTML,JS,PHP code from api output php?

  24. 24

    Modify Html form submit output

  25. 25

    Output HTML form to .txt file

  26. 26

    Karate API Testing - How to use a variable (output from response) from API 1 to another API in same feature

  27. 27

    How to extract an embedded link from an as text saved html document OR how to use xidel to extract the correct link?

  28. 28

    Use data from sql table in a html form with php

  29. 29

    How to get the value from html form and use it in views.py?

HotTag

Archive