Copying value of a textbox to a nother using ajax in jsf -
i new ajax , trying copy value of 1 box another. here code:
<h:form> <h:inputtext value="#{ajaxbean.name}"> <f:ajax render="otherbox" execute="@this" event="keyup"></f:ajax> </h:inputtext> <h:inputtext id="otherbox" value="#{ajaxbean.name}"></h:inputtext> </h:form>
and bean
@named(value = "ajaxbean") @dependent public class ajaxbean { public ajaxbean() { } private string name; public string getname() { return name; } public void setname(string name) { this.name = name; } }
that code not work. can me?
thanks
your question not ajax or jsf. javascript question.
you can access , modify items javascript.
add javascript codes between <h:head></h:head>
<script> function copyfield() { document.getelementbyid("field2").value = document.getelementbyid("field1").value; } </script>
and page:
<h:form id="myform" prependid="false"> <h:inputtext id="field1" value="#{mybean.name}" onkeyup="copyfield();" /> <h:inputtext id="field2" value="#{mybean.name}"></h:inputtext> </h:form>
take attention prependid="false" avoid mixing ids.
see also:
Comments
Post a Comment