I have node/express Application which is using ejs template as views. I 
have a drop down in ejs which is generated dynamically and it is working 
fine. I want to show/display the value selected from dropdown in a text box 
but my code is not working . I am able to do it in couple of ways in plain 
HTML/JS but not working in ejs.


Here is my code:

It seems run() is getting executed on selecting option from dropdown menu .

Any help will be greatly appreciated 


<!DOCTYPE html><html><head>
    <meta charset="utf-8"  http-equiv="refresh" content="7" >
    <title>Flow Meter Dashboard </title></head>
<body>
<h1> <%= title%></h1> <br>
<ul>
<% for(var key in Data){ %>
      <%    var k=key;%>
        <%var v=Data[key];%>
        <li><%= k %> <%=":"%> <%=v%></li>
        <%} %>
</ul>
<form action="http://127.0.0.1:8081/"; method="POST">
Water Recharge Amount: <br><!-- <input type="text"   name="WaterBalance"  
value= wb    > --><input type="submit" name="Recharge_Amount" value="100" > 
<input type="submit" name="Recharge_Amount" value="200"><br><br><input 
type="submit" name="Recharge_Amount" value="500" > <input type="submit" 
name="Recharge_Amount" value="1000"><br>
<br> Switch ON RO Purifier: <input type="submit" name="Switch_ON" value="ON" > 
<br><br>Switch OFF RO Purifier: <input type="submit" name="Switch_OFF" 
value="OFF" > <br>
</form>Select RO<br><input type="text" id="srt" placeholder="select RO id"><br>
<%function run() {%>
        <%var e = document.getElementById("drpdwn");%>
        <%var strUser = e.options[e.selectedIndex].text;%>
        <%document.getElementById("srt").value =strUser;%>
   <% }%><br>
<select id="drpdwn"  onchange="run();"><option value="Select_RO" 
selected>Select RO</option><%for(var i=0;i<ro.length;i++){ %><option value='<%= 
ro[i]%>'/><%=ro[i]%> </option><% }%>                 </select></body></html>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/b5a2e006-e703-4ad5-b104-72db5c209a81%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to