javascript中的问题
javascript验证中的问题,如何调用javascriptjavascript中的问题,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
<!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是什么样子的?脚本标记仍然存在吗?代码中仍然有一些模糊的地方。
丢失,
和
应该放在表单中(或者
或者
)。如果有
而不是
,它将呈现。没错,它不是用于浏览器的javascript。我没想到:)谢谢!但我仍然有同样的问题,请看代码,让我知道问题是什么。这是一个,根据,它是支持的。顺便说一下,它是onclick
,而不是onclick
。
<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>