S
swe_dev1
Hello,
I am trying to get a JSF-form to call a javascript and passing a
component id as a variable, but somehow the variable remains undefined
when seen by the java script. I simply want to make a drop down menu
("county") to be automatically populated when a choice is made in
another drop down menu ("district") without reloading the page. My jsf
looks like this:
<html>
<head>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<script language="JavaScript" src="autopop.js"></script>
</head>
<body>
<f:view>
<h:form id="searchform1">
<h:selectOneMenu id="district"
onchange="menuSelect(this,document.forms.searchform1.county);">
<f:selectItem itemValue="aa" itemLabel="District 1"/>
<f:selectItem itemValue="ab" itemLabel="District 2"/>
<f:selectItem itemValue="ac" itemLabel="District 3"/>
<f:selectItem itemValue="ad" itemLabel="District 4"/>
</h:selectOneMenu>
<h:selectOneMenu id="county" styleClass="infield"></h:selectOneMenu>
</h:form>
</f:view>
</body>
<html>
As you can see, two variables are passed, "this", which works fine, and
"document.forms.searchform1.county" which gets a null value. When I do
this without JSF it all works fine, but JSF renames the component id:s
(it adds the form name and semicolon). Therefore I can't seem to
reference it properly...
What am I doing wrong? Is there another, more "JSF-ish" way to do this?
Any help is greatly appreciated!
/Erik
I am trying to get a JSF-form to call a javascript and passing a
component id as a variable, but somehow the variable remains undefined
when seen by the java script. I simply want to make a drop down menu
("county") to be automatically populated when a choice is made in
another drop down menu ("district") without reloading the page. My jsf
looks like this:
<html>
<head>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<script language="JavaScript" src="autopop.js"></script>
</head>
<body>
<f:view>
<h:form id="searchform1">
<h:selectOneMenu id="district"
onchange="menuSelect(this,document.forms.searchform1.county);">
<f:selectItem itemValue="aa" itemLabel="District 1"/>
<f:selectItem itemValue="ab" itemLabel="District 2"/>
<f:selectItem itemValue="ac" itemLabel="District 3"/>
<f:selectItem itemValue="ad" itemLabel="District 4"/>
</h:selectOneMenu>
<h:selectOneMenu id="county" styleClass="infield"></h:selectOneMenu>
</h:form>
</f:view>
</body>
<html>
As you can see, two variables are passed, "this", which works fine, and
"document.forms.searchform1.county" which gets a null value. When I do
this without JSF it all works fine, but JSF renames the component id:s
(it adds the form name and semicolon). Therefore I can't seem to
reference it properly...
What am I doing wrong? Is there another, more "JSF-ish" way to do this?
Any help is greatly appreciated!
/Erik