Menu

addUser()

Bhargav Ekbote

The addUser() function is located in the kwitter.js file. It carries out the login process in LetsChat. The index.html page and login pages, in general, depend on this function (indirectly depending on the kwitter.js file). It also requires having a kwitter_room.html page/file.

This line fetches the value from the id user_name and attaches the value to the user_name variable:

user_name = document.getElementById("user_name").value;
  ```
An example of how to get the user to attach a value to the id <code>user_name</code>, which is typically done through the <code>index.html</code> page:
:::HTML

<input type="text" name="user-field" id="user_name">

This line stores the <code>user_name</code> in the browser's local storage. Saving data in local storage allows the data to persist even if the browser is closed:
:::JavaScript

localStorage.setItem("user_name", user_name);

This line redirects the user to the <code>kwitter_room.html</code> page, completing the login process:
:::JavaScript

window.location = "kwitter_room.html";

After this process, the <code>kwitter_room</code> page should display the entered <code>user_name</code> value that was previously entered on the <code>index.html</code> login page.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.