How do I get the value of text input field using JavaScript
I got stuck with this for 2 days, please help me
Actually my logic is when I enter the input on the text field in browser, the entered input to be print on the next page but I am getting "Undefined". How to i do it.
Below is my code:
{
/// Class name of application this page belongs to.
Parameter APPLICATION;
/// Displayed name of this page.
Parameter PAGENAME = "userLogin";
/// Domain used for localization.
Parameter DOMAIN;
/// This Style block contains page-specific CSS style definitions.
XData Style
{
<style type="text/css">
/* style for title bar */
#title {
background: #C5D6D6;
color: black;
font-family: Verdana;
font-size: 1.5em;
font-weight: bold;
padding: 5px;
border-bottom: 1px solid black;
text-align: center;
}
#login{
text-align: center;
font-family: Ariel;
font-size: 3.5em;
padding: 180px;
font-color: brown;
}
#content{
text-align: left;
font-size: 1.5em;
font-color: default;
font-family: default;
}
#content1{
text-align: left;
font-size: 1.5em;
font-color: default;
font-family: default;
}
#button{
text-align: left;
font-size: 1.5em;
font-color: default;
font-family: default;
}
</style>
}
/// This XML block defines the contents of this page.
XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ]
{
<page xmlns="http://www.intersystems.com/zen" title="">
<html id="title">Welcome!!!</html>
<vgroup width="100%">
<html id="login">Login</html>
<html id="content">Patient Id:</html>
<text id="patientId" value=""/>
<html id="content1">Password:</html>
<text id="patientPass" value=""/>
<button id="button" caption="Login" onclick="zenPage.MyMethod();"/>
</vgroup>
</page>
}
ClientMethod MyMethod() [ Language = javascript ]
{
var pId=document.getElementById("patientId").value;
var pPass=document.getElementById("patientPass").value;
document.write(pId,pPass);
}
}
Thanks
Vikram
Comments
you operate not on document object but on zenPage object
see docs: Client Side Functions, Variables, and Objects at the beginning >>>
Thanks Robert,
I missed this doc. Now I got some idea.
Thanks you so much....![]()
You can open your page in Chrome and then using developers Tool, you can see that ZEN page randomly assigns the ID to Components.
So best way to use zen(<ComponentID>).getValue() or setValue() for getting and setting the value.
.png)
Thanks Sourabh,
Its a wonderful idea. This make me a different way of thinking.
Thanks a lot....![]()