2011-11-07 73 views
1

大家好我是尝试使用的document.getElementById(“someid”)如何从JSF页面的inputText使用JavaScript

这里从一个JSF页面的领域中获取价值是实际的代码

提取值
 <h:form id="hell"> 
       <h:panelGrid columns="12" border="0"> 
        <h:outputLabel>Airlines</h:outputLabel> 
        <h:selectOneMenu value="#{planeMngr.PM.airline_no}" styleClass="inputbox" style="width:150px"> 
         <f:selectItems value="#{projectUtil.airlineList}" var="AList" itemLabel="#{AList.name}" itemValue="#{AList.name}"/> 
        </h:selectOneMenu> 
        <h:outputLabel>Source</h:outputLabel> 
        <h:selectOneMenu value="#{planeMngr.PM.source}" styleClass="inputbox" style="width:150px"> 
         <f:selectItems value="#{projectUtil.contyList}" var="RList" itemLabel="#{RList.country_Name}" itemValue="#{RList.country_Name}"/> 
        </h:selectOneMenu> 
        <h:outputLabel>Destination</h:outputLabel> 
        <h:selectOneMenu value="#{planeMngr.PM.destination}" styleClass="inputbox" style="width:150px"> 
         <f:selectItems value="#{projectUtil.contyList}" var="RList" itemValue="#{RList.country_Name}"/> 
        </h:selectOneMenu> 

        <h:outputLabel>Departure Date</h:outputLabel> 
        <h:inputText id ="depday" value="#{planeMngr.PM.departure_date}" label="dd/mm/yyyy" > 
         <f:convertDateTime pattern="dd/MM/yyyy" dateStyle="full" ></f:convertDateTime> 

        </h:inputText> 



        <h:outputLabel>Departure Time </h:outputLabel> 
        <h:inputText id="deptime" value="#{planeMngr.PM.departure_time}" label="HH:MM" > 
         <f:convertDateTime pattern="HH:mm"></f:convertDateTime> 
        </h:inputText> 



        <h:outputLabel value="Status"/> 
        <h:selectOneMenu label="Status" value="#{planeMngr.PM.status}"> 
         <f:selectItem itemLabel="PreFlight" itemValue="PreFlight" /> 
         <f:selectItem itemLabel="Open" itemValue="Open" /> 
         <f:selectItem itemLabel="Restricted CheckIn" itemValue="Restricted_CheckIn" /> 
         <f:selectItem itemLabel="Restricted" itemValue="Restricted" /> 
         <f:selectItem itemLabel="Closed" itemValue="Closed" /> 
         <f:selectItem itemLabel="Released" itemValue="Released" /> 
        </h:selectOneMenu> 
       </h:panelGrid> 
       <h:commandButton onclick="return datevalidate()" action="#{planeMngr.ADD}" value="save" ></h:commandButton> 
      </h:form> 

这里是我的JS代码。其中我只是检查由用户填写的字段中的值是什么。

function datevalidate() 
{ 
    var dat = document.getElementById("hell:deptime"); 
var day = document.getElementById("hell:depday"); 
alert(dat +" time "+day); // this gives "[object HTMLInputElement] time [object HTMLInputElement]" as an out put 
return false; 
} 

告诉我我在做什么错在这里?

回答

1

在JavaScript中摆脱HTMLInputElement值使用其value字段:

alert(dat.value +" time "+day.value); 
+0

由于其现在的工作。 – ifti