在prestashop模块文件中添加一组jquery内联代码不起作用


add jquery bunch of inline codes in prestashop module file not working

我只是prestashop的新手。目前我正在prestashop中创建一个小模块。我想在modulename.php文件中添加一些jQuery内联代码。但它在那里不起作用。有人能告诉我如何将jQuery代码用于prestashop模块文件吗。任何帮助和建议都将非常有用。感谢

我的示例代码如下

public function getContent() {
      $this->_html = '<h2>'.$this->displayName.'</h2>';
    if (Tools::isSubmit('submitUpdate')) {
      Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'tablename` SET `function_name`="'.$body_option.'",`height`="'.$height.'",`width`="'.$width.'"');
      $this->_displayForm();
      return $this->_html;
    }
  }

  private function _displayForm() {
    $this->_html .=  '
      <link rel="stylesheet" href="../modules/modulename/css/store_styles.css" />
      <script src="../modules/modulename/js/jquery-1.7.2.min.js" type="text/javascript"></script>';
      $this->_html .= '<input type="file" name="file" id="file"  multiple/>';
    $this->_html .= '
      <form method="post" action="'.$_SERVER['REQUEST_URI'].'" id="test">';
    $this->_html .= '<div class="clear"></div></div>
      <label>'.$this->l('Upload Image').' </label>
      <div class="margin-form">';
      $this->_html .= '<input type="file" name="file" id="file"  multiple/>';
      $this->_html .= '</div>';
        $this->_html .= '
        <div class="margin-form clear"><input type="submit" name="submitUpdate" value="'.$this->l('Save').'" class="button" /></div>
        </form>      
  }

所以根据我的要求,当我点击复选框时,这段代码应该可以工作。

 <script type="text/javascript">
  jQuery('input[name="file"]').change(function(){
    if(jQuery(this).val() == 'yes'){
      jQuery('input[type="file"]').prop('multiple', true);
    }else{
        jQuery('input[type="file"]').prop('multiple', false);
    }
  });
</script>

请记住此表单是用于管理员的,我希望在后台使用jQuery代码。

我不会使用本地的,请尝试以下操作:

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>