Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

117
Views
Prompt not taking user input from client side

Hey Stack Overflow geeks, I'm working on a real-time chat application using HTML, CSS, and js using socket.io. There I've been created an index.js file that stores the user information and strikes back the same and the other one named client.js which takes the name of the user using prompt. Both of the files has been given below

index.js

const io = require('socket.io')(5000)
const users = {};
io.on('connection', socket =>{
    socket.on('new-user-joined', user =>{
        console.log("New user", user)
        users[socket.id] = user;
        socket.broadcast.emit('user-joined', user);
    });
    socket.on('send', message=>{
        socket.broadcast.emit('receive', {message: message, name: users[socket.id]})
    });
})

client.js

const socket = io('https://localhost:5000');
const form = document.getElementById('send-container');
const messageIn = document.getElementById('messageIn');
const messageContainer = document.querySelector('.container');
const user = prompt("Enter your username")
socket.emit('new-user-joined', user);

Now the problem is that the client.js file didn't fire up the prompt for taking user input. Since I'm currently in the learning phase of web development I tried my best to know where am I getting wrong but didn't find the appropriate solution. Please help me to get to know where am I going wrong.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!