在页面上生成Youtube Url Thumb Image加载PHP

时间:2014-07-03 06:12:27

标签: php

我想在页面加载事件中生成Youtube Thumb从文本框(文本框数组)中给出的值。包含带有值的文本框的表单代码如下所示。请帮助我解决此问题。

<script language="javascript">
function getthumbonload()
    {
    var msg1 = document.getElementById('video_url[]').value;

    var str1 = msg1;
    var parts1 = str1.split("/");
    var tmp1 = parts1[parts1.length-1];
    somestr1 = "http://img.youtube.com/vi/"+ tmp1+"/3.jpg?a="+Math.random();
    }
</script>
<form name="frmupdate" method="post" id="formID" action="videos_db.php" >
    <?php
    if ($totalRecords > 0) {
        $perColumn = 2;
        $colWidth = floor(100 / $perColumn);
        $Totalrows = ceil($totalRecords / $perColumn);
        ?>

        <body onload="getthumbonload();">
        <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="tblbg">
            <tr>
                <td>
                <table width="100%" border="0" cellspacing="1" cellpadding="2">
                    <tr>
                        <td colspan="<?php echo $perColumn; ?>" valign="top" class="tblheader">Edit / Delete Videos<br />
                           </td>
                    </tr>
                    <?php
                    $mainCnt = 1;
                    for ($rowCnt = 1; $rowCnt <= $Totalrows; $rowCnt++) {
                    ?>
                    <tr>
                        <?php for ($colCnt = 1; $colCnt <= $perColumn; $colCnt++) { ?>
                        <td width="<?php echo $colWidth; ?>%" valign="top" class="tblrow">
                    <?php
                    if ($mainCnt <= $totalRecords && mysql_data_seek($result, $mainCnt - 1) && $arow = mysql_fetch_array($result)) {
                    ?>
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td align="center"><input name="video_id[]" type="checkbox" id="video_id[]" value="<?php echo $arow["video_id"]; ?>" /></td>
                        </tr>
                        <tr>
                            <td align="center" class="tblrow">
                             <input type="label" class="input" name="title[]" value="<?php echo $arow["title"]; ?>" />
                            </td>
                        </tr>
                        <tr>
                            <td align="center" class="tblrow">
                            <input name="video_url[]" type="text" class="input videoURLTXT" id="video_url[]" value="<?php echo setDB($arow["video_url"], "display"); ?>" maxlength="100" /><input name="vid_id[]" type="hidden" value="<?php echo $arow["video_id"]; ?>" /></td>
                        </tr>
                        <tr>
                    <td align="center" class="tblrow"><img src="" id="videoThumb"></td>
                         </tr>

                    </table>

                    <?php }
                        else echo "&nbsp;"; ?>

                    </td>
                        <?php
                        $mainCnt++;
                        }
                        ?>      
                </tr>
            <?php
                }
            ?>      
                    </table>
                </td>
            </tr>
        </table>
        </body>
         <br />
        <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td><input name="btnupdate" type="submit" class="but" id="btnupdate" value="Update All" />
                    &nbsp;
                    <input name="btndel" type="button" class="but" id="btndel" value="Delete Selected" onclick="setAction('delete');" /></td>
            </tr>
            <tr>
                <td>&nbsp;</td>
            </tr>

        </table>
        <input type="hidden" name="myaction" value="update">
        <input type="hidden" name="cid" value="<?php echo $cid; ?>" />
        <input type="hidden" name="modelid" value="<?php echo $modelid; ?>" />



    <?php
}
else
    echo "<center class=\"tblrow1\">No Records found.</center>";

mysql_free_result($result);
?>
</form>

提前致谢

0 个答案:

没有答案