Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/381.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
javascript中的问题_Javascript_Jsf_Icefaces - Fatal编程技术网

javascript中的问题

javascript中的问题,javascript,jsf,icefaces,Javascript,Jsf,Icefaces,javascript验证中的问题,如何调用javascript <!DOCTYPE html> <f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ice="http://www.ices

javascript验证中的问题,如何调用javascript

<!DOCTYPE html>
<f:view xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ice="http://www.icesoft.com/icefaces/component">

<html>
<head>
<script type="text/javascript">
alert('1');
function validate()
{
   alert('inside function');
   var str1;
  // str1 = document.getElementById('name').value;
   //alert(str1);

}    

</script>
</head>
<body>
<ice:panelGrid columns="1" width="760px" styleClass="contentPanel">
<ice:panelGroup>
<ice:outputText value="Name"></ice:outputText>
<ice:inputText value="" id="name" ></ice:inputText>
<ice:commandButton onclick="validate();"></ice:commandButton>

</ice:panelGroup>

</ice:panelGrid>
</body>
</html>

警报(“1”);
函数验证()
{
警报(“内部功能”);
var-str1;
//str1=document.getElementById('name')。值;
//警报(str1);
}    


我无法访问javascript。获取错误为未定义验证

看起来您的
标记未关闭。它能渲染吗?

我对冰软软件的东西一无所知。您确定它支持“onclick=”吗

就HTML而言,它看起来不错

一个没有这些东西的简单例子:


警报(“1”);
函数验证()
{
警报(“内部功能”);
var-str1;
}

对我来说很好。

您的代码似乎正确,只是您必须将所有
inputText
commandButton
组件嵌套在一个表单中:

<body>
    <f:form>
        <ice:panelGrid columns="1" width="760px" styleClass="contentPanel">
            <ice:panelGroup>
                <ice:outputText value="Name"/>
                <ice:inputText value="" id="name"/>
                <ice:commandButton onclick="validate();"/>
            </ice:panelGroup>
        </ice:panelGrid>
    </f:form>
</body>


好的,但是你想在哪里执行呢?onClick?在其他函数中?发布完整的相关代码。如果在web浏览器中打开页面并单击“查看源代码”,html是什么样子的?脚本标记仍然存在吗?代码中仍然有一些模糊的地方。
丢失,
应该放在表单中(或者
或者
)。如果有