Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<table class="table" id="table" >

      <th colspan="2">welcome</th>
       <tr >

            <td type="ftd" >
                <input list="city"   placeholder="select ur city"   />
                <div id="listcity">
                <datalist id="city" class="listcity">
                <option value="egypt">
                <option value="abo dubi">
                <option value="syria">
                <option value="italy">
                <option value="engeland">
                </datalist>
                    </div>
           </td>
      </tr>

      <tr>

             <td ><input type="text" placeholder="username:" /></td>
       </tr>
       <tr>

             <td ><input type="password" placeholder="Enter password" /></td>
       </tr>

       <tr>
             <td ><input type="password" placeholder="confirm ur password" /></td>
       </tr>

        <tr>
            <td ><input type="tel" placeholder="your phone number" /></td>
        </tr>

       <tr>
            <td><input type="submit" id="submit";
       ondblclick="tableval ()" value="submit" /></td>
        </tr>

      </table>


What I have tried:

get td values from table by js
Posted
Updated 5-Jul-21 22:30pm
Comments
gggustafson 5-Jul-21 17:53pm    
What is tableval ()

1 solution

You need to either assign a name or an id to your input elements so you can select them and read the values. For example:

// HTML
<input type="text" name="username">
<input type="password" id="password">

// JS
const username = document.getElementsByName("username")[0].value;
const password = document.getElementById("password").value

Alternatively, provided you give your inputs valid names, you can use the FormData object and provide the parent form. Simply wrap the input elements in a form, give it an id and:
// HTML
<form id="some-form"> .. </form>

// JS
const form = document.getElementById("some-form");
const data = new FormData(form)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900