The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> Using the <input> tag, Two <input type="text"> tags on the same page.
Rayj00
post 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! smile.gif

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



User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
 
Reply to this topicStart new topic
Replies
CharlesEF
post Jun 1 2020, 03:57 PM
Post #2


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



I don't think you've posted enough code for anyone to help. You say the 1st input works but looking at the code, it does nothing. There must be an event listener defined somewhere. The 2nd input is inside a form so the input will only submit its data when the form is submitted but you have no submit button defined.

Maybe someone else can see things I don't.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Rayj00
post Jun 1 2020, 05:30 PM
Post #3





Group: Members
Posts: 6
Joined: 1-June 20
Member No.: 27,369



QUOTE(CharlesEF @ Jun 1 2020, 04:57 PM) *

I don't think you've posted enough code for anyone to help. You say the 1st input works but looking at the code, it does nothing. There must be an event listener defined somewhere. The 2nd input is inside a form so the input will only submit its data when the form is submitted but you have no submit button defined.

Maybe someone else can see things I don't.


Well, when I click the button on the first one, it works as designed. No problem.

It's the second one. When I click the "Send" button, it actually sends whatever is in the first input text box!
So I guess just ignore the first input as it works fine.

Why does the second input get the text from the first input rather than it's own text?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 27th April 2024 - 06:15 AM