Javascript在PHP中不起作用。

边缘

我的剧本:

<?php
include 'theme.php';
/*ceklogin();*/
css();
if($_POST['wget-send'])
    {
        $formdir=$_POST['dir'];
        $formlink=$_POST['link'];
    $filelink = fopen('/root/wget/wget-download-link.txt',a);
    $filedir = fopen('/root/wget/wget-dir.txt',w);

    fwrite($filedir, $formdir);
    fwrite($filelink, $formlink."\n");
    /*
    exec('touch /root/wget/wget-download-link.txt',$out);
    exec('echo "'.$link.'" >> /root/wget/wget-download-link.txt',$out);
    exec('echo "'.$dir.'" > /root/wget/wget-dir.txt',$out);
        echo $out[2];
        exit();
    */
    }
echo "<form action=\"".$PHP_SELF."\" method=\"post\" id=\"WgetForm\">";
echo "Download directory:<br><input type=\"text\" name=\"dir\" size=\"15\" value=\"/mnt/usb/\"/><br>";
echo '<br><br>Download link:';
echo "<br><input type=\"text\" name=\"link\" size=\"62\" value=\"\"/><br><br>";
echo '<input type="submit" onclick="LinkAdded()" name="wget-send" value="Send" id="WgetID"/>';
echo "</form></div>";
echo '<script type="text/javascript">';

'function LinkAdded()'
    '{
            document.getElementById("WgetID").innerHTML = "Link added to wget";
    }'
'</script>'

foot();
echo '
</div>
</body>
</div>
</html>';
?>

我仍然不太了解如何在PHP中编写javascript,它给了我一个错误:

Parse error: syntax error, unexpected ''{' (T_CONSTANT_ENCAPSED_STRING) in /www/wget.php on line 33

但是,如果我将javascript放在<? ....?>页面的外面,效果很好,但是javascript无法正常工作。请帮忙。

查理

我不会解析您的语法错误。自己使用代码短绒来做到这一点。如今,它们甚至都内置在免费的IDE中,您甚至可以将代码粘贴到在线语法检查器中

您没有为input您设置innerHTMLvalue

改变

document.getElementById("WgetID").innerHTML = "Link added to wget"

document.getElementById("WgetID").value = "Link added to wget"

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章