2012-07-25 2 views
0

도시와 국가의 위치 정보 데이터로 채우기를 원하는 두 개의 inputtext가 있습니다.미리 채우기하는 방법 h : inputText in

<h:inputText id="city" style="width:100%;" value="#{m.city}"></h:inputText> 

<h:inputText id="city" style="width:100%;" value="#{m.country}"></h:inputText> 

답변

0

첫째 : 이 내가 위치를

 <script language="JavaScript" src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script> 

    <script language="Javascript"> 
    document.write(geoplugin_city(), geoplugin_countryName()); 
    </script> 

JSF를 얻기 위해 사용하려는 API를 당신이 당신의 inputText

시도 국가로 두 번째를 변경 뭔가에 동일한 ID를 준 이처럼

document.getElementById("yourFormId:city").value = geoplugin_city(); 
document.getElementById("yourFormId:country").value = geoplugin_countryName(); 
+0

작품! 감사합니다 –

+0

당신은 오신 것을 환영합니다. – Daniel

0

그런데 왜 도시와 countryName을 ID로 설정할 JavaScript 함수를 만들지 않겠습니까? (ID 도시와 국가를 가질 것입니다. 이제는 모두 inputText에 대해 동일한 ID를가집니다). 페이지가로드 될 때 호출하면 question에 따라이를 수행하는 방법이 두 가지 있습니다.

관련 문제