Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/438.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
将参数从velocity传递到javascript_Javascript_Velocity - Fatal编程技术网

将参数从velocity传递到javascript

将参数从velocity传递到javascript,javascript,velocity,Javascript,Velocity,我添加了onfocus和onclick来选择和编写java脚本函数,如下所示。使用velocity,即.vm文件调用javascript函数 <script type="text/javascript"> function fixA(val){ alert(val); // document.getEleme

我添加了onfocus和onclick来选择和编写java脚本函数,如下所示。使用velocity,即.vm文件调用javascript函数

    <script type="text/javascript">
                function fixA(val){
                    alert(val);                              
                   // document.getElementById(val).style.zIndex="100";
                   val.style.zIndex=300;
                }
                function fixB(val){
                    alert(val);                               
                   // document.getElementById(val).style.zIndex="300";
                      val.style.zIndex=300;
                }

            </script>


#elseif ( $el.type.code == "listbox" )
#if( $errorFields.contains($name) )
    <div class="label selectbox big error"> 
#else
    <div class="label selectbox big" >
#end
    #if ($el.label)
        #if ($el.mandatory)
            <label class="label_content" for="$name">$el.label *</label>
        #else
            <label class="label_content" for="$name">$el.label</label>
        #end
    #end
    <select class="select_styled" id="$name" name="$name" onfocus="fixA($name)" onclick="fixB($name)" >
        #foreach($val in $el.values)
            #set ($sel = "")
            #if ($allInputFields.get($name) == $val)
                #set ($sel = ' selected="selected"')
            #end
            <option$sel onclick="resetIndex()">$val</option>
        #end
    </select>
    <div class="clr">
    </div>
</div>
1我正在使用IE7,但它不工作,在FF中工作正常


2 alertval给出了[object HTMLSelectElement]的值,但是alert document.getElementByIdval;给出空值。如何解决它?

变量s不是ID,它已经是元素的引用。

变量s不是ID,它已经是元素的引用。

主要错误您需要引用名称fixA'$name'

最好通过这个:onfocus=fixAthis

function fixA(sel){
  sel.style.zIndex=100; // int, not a string
}
看来你找错人了

该插件将DOM重写为一组div


而您使用的jQuery selectbox插件应该正是您想要实现的,但由于IE7的某些特定原因而失败:$container.cssz-index,10000

主要错误您需要引用名称fixA'$name'

最好通过这个:onfocus=fixAthis

function fixA(sel){
  sel.style.zIndex=100; // int, not a string
}
看来你找错人了

该插件将DOM重写为一组div


而您使用的jQuery selectbox插件应该正是您想要实现的,但由于IE7的某些特定原因而失败:$container.cssz-index,10000

如果没有引号,它将传递一个名为$name的对象,而不是字符串$name。这将是null或未定义的


在onclick中用单引号引用$name:onclick=fixA'$name'

如果没有引号,它将传递一个名为$name的对象,而不是字符串$name。这将是null或未定义的

在onclick中用单引号引用$name:onclick=fixA'$name'

如下更改:

<select class="select_styled" id="$name" name="$name" 
        onfocus="fixA('$name')" onclick="fixB('$name')">
这样改变它:

<select class="select_styled" id="$name" name="$name" 
        onfocus="fixA('$name')" onclick="fixB('$name')">

但这是一个完全不同的问题-顺便说一句,在IE8中有效,但这是一个完全不同的问题-顺便说一句,在IE8中有效