Note that there are some explanatory texts on larger screens.

plurals
  1. POGrab value from URL without page refresh or button click
    primarykey
    data
    text
    <p>I currently created a form that will take youtube links and parse/regex extracts the ID. The function is executed through a button click which then prints the ID of the <code>URL</code>. Is there a way to have it display the <code>ID</code> without a button click and a page refresh? <a href="http://webprolearner2346.zxq.net/testYTvid/test.php" rel="nofollow">EXAMPLE</a></p> <pre><code>if(isset($_POST['ytinput'])){ function getYoutubeId($sYoutubeUrl) { # set to zero $youtube_id = ""; $sYoutubeUrl = trim($sYoutubeUrl); # the User entered only the eleven chars long id, Case 1 if(strlen($sYoutubeUrl) === 11) { $youtube_id = $sYoutubeUrl; return $sYoutubeUrl; } # the User entered a Url else { # try to get all Cases if (preg_match('~(?:youtube\.com/(?:user/.+/|(?:v|e(?:mbed)?)/|.*[?&amp;]v=)|youtu\.be/)([^"&amp;?/ ]{11})~i', $sYoutubeUrl, $match)) { $youtube_id = $match[1]; return $youtube_id; } # try to get some other channel codes, and fallback extractor elseif(preg_match('~http://www.youtube.com/v/([A-Za-z0-9\-_]+).+?|embed\/([0-9A-Za-z-_]{11})|watch\?v\=([0-9A-Za-z-_]{11})|#.*/([0-9A-Za-z-_]{11})~si', $sYoutubeUrl, $match)) { for ($i=1; $i&lt;=4; $i++) { if (strlen($match[$i])==11) { $youtube_id = $match[$i]; break; } } return $youtube_id; } else { $youtube_id = "No valid YoutubeId extracted"; return $youtube_id; } } } print 'Result: ' . getYoutubeId($_POST['ytinput']); } ?&gt; &lt;form action="" method="POST"&gt; &lt;input type="text" name="ytinput" value="&lt;? $sYoutubeUrl ?&gt;"&gt; &lt;input type="submit" value="Parsen"&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload