Did you find solutions to this? To me, I can't even call document in js
function since ejs cannot manipulate with dom objects directly.
On Tuesday, July 26, 2016 at 6:38:16 AM UTC-7, Maneesh Rao wrote:
>
> 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/120f3271-5e53-4e0d-8125-e9047273e087%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.