Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/418.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
wordpress控件中的Javascript_Javascript_Wordpress - Fatal编程技术网

wordpress控件中的Javascript

wordpress控件中的Javascript,javascript,wordpress,Javascript,Wordpress,我是新创建wordpress小部件的,我想创建一个小部件,它将上传一个图像并显示在网站的首页上,为了实现这一点,我正在编写下面的代码,但是javascript在我的代码中没有正常运行,下面的代码在WP_my_widget类和default-widgets.php文件中编写,实际上,当我试图提醒加载文件的计数时,javascript代码没有运行,它只是显示0 public function form( $instance ) { // outputs the options form on adm

我是新创建wordpress小部件的,我想创建一个小部件,它将上传一个图像并显示在网站的首页上,为了实现这一点,我正在编写下面的代码,但是javascript在我的代码中没有正常运行,下面的代码在WP_my_widget类和default-widgets.php文件中编写,实际上,当我试图提醒加载文件的计数时,javascript代码没有运行,它只是显示0

public function form( $instance ) {
// outputs the options form on admin
?>
<br/>

Please Enter The URL of Leading Site: <input type='text' name='url' id='url'/><br/>
Upload new image: <input type='file' name='images' id='images'><br/>
<br/><a href='javascript:void(0);' id='myid' onclick='abc();'>Proceed Uploaded File!</a>
<script>
    function abc(myurl){
    myLocalFiles = document.getElementById('images');
    len = myLocalFiles.files.length;
    alert(len);             
    }        
</script>       
<?php              
}
公共函数表单($instance){
//在admin上输出选项窗体
?>

请输入领先网站的URL:
上载新图像:

函数abc(myurl){ myLocalFiles=document.getElementById('images'); len=myLocalFiles.files.length; 警报(len); } 你应该试试

myLocalFiles = document.getElementById('images').files;
len = myLocalFiles.length;
alert(len); 
检查这个

我认为这不是文字新闻的问题