function passString(str)
{
alert(str);
}
function passText()
{
str = document.getElementById('formId:hidden1').value;
alert(str);
}
I am using both of the above javascript functions to get the string obtained from a jsf bean file but none is working. The string is successfully obtained from the "#{addRoute5.teamNames}"(jsf bean File - see below) and displayed in the inputText, but the javascript cant accept string for some reason from xthml. My code in xhtml file is as follows:
Thanks in advance
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<f:view>
<h:head>
<link href="css/myCss1.css" rel="stylesheet" type="text/css"/>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Paris-Dakar Rally</title>
<link href="css/mapsStyle.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="//maps.googleapis.com/maps/api/js? sensor=false"></script>
</h:head>
<h:body onload ="#{addRoute5.calculateLatMarker()}">
<div id="container">
<div id="header">
<div id="title">
<span>Paris - Dakar Rally</span>
</div>
</div>
<div id="map_canvas"></div>
<h:form id="formId">
<div id="body">
<div class="transbox">
<h:inputText id="hidden1" value="#{addRoute5.teamNames}"/>
**<h:commandButton type ="button" value="Start Simulation" onclick ="passText()" or onclick="passString(#{addRoute5.teamNames})"/>**
</div>
</div>
</h:form>
</div>
</h:body>
</f:view>
</html>
passText()approach should work, but it is clumsy. ThepassString()approach has an obvious syntax error which you can already answer/solve yourself by just looking at the generated HTML output or at the browser's JS console. I can of course post it as an answer, but that wouldn't explain whypassText()don't work and I'm also curious what exactly the functional requirement is which you're trying to solve, because there may be much better ways to achieve this than something clumsy like this.<h:inputText>, not a HTML<input>.