Using the <input> tag, Two <input type="text"> tags on the same page. |
Using the <input> tag, Two <input type="text"> tags on the same page. |
Rayj00 |
Jun 1 2020, 12:46 PM
Post
#1
|
Group: Members Posts: 6 Joined: 1-June 20 Member No.: 27,369 |
I admit I am not a seasoned website developer, so have mercy on me! So, I have two <input type="text"> on the same page. Here is the first one: CODE <input type="text" id="broadcast-id" value="room-xyz" autocorrect=off autocapitalize=off size=20> <button id="open-or-join">Open or Join Broadcast</button> And here is the second one: CODE <div> <h2>Messages</h2> <ul></ul> </div> <form action=""> <input class="msgs" type="text" id= 'msgs' /> <button>Send</button> </form> So the first one works fine. But the second one grabs the text from the first one instead of what is typed in it's own text box. I am using some sample code to add a messaging option in the page from https://www.ably.io/concepts/socketio Any ideas why the second input is grabbing the first input text? Thanks, appreciate your response. Ray |
Christian J |
Jun 3 2020, 02:50 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,630 Joined: 10-August 06 Member No.: 7 |
You could use two copies of the javascript, that each gets its data from different forms and textfields. To do so, use different IDs for the FORM and INPUT elements and target those IDs in querySelector, like
CODE <form id="form1" method="post" action=""> with CODE ...querySelector('#form1'); etc. But I don't know if the server-side script can handle submissions from multiple forms (or if you want it to do that). |
Lo-Fi Version | Time is now: 28th March 2024 - 11:40 PM |