PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, October 27, 2022

[FIXED] How to get input value with no id using JavaScript?

 October 27, 2022     asp.net-mvc, datatable, html, javascript, jquery     No comments   

Issue

I have an editable DataTabe and when edit mode, the generated html is exactly as shown below:

<td><form><input autocomplete="off" name="value" ></form></td>

There is s TextBox as input and I need t get the value of this input. However, I cannot give id as there is no configuration of DataTable and I decided to get the value using Javaascipt. I have tried many different methods like closest() as shown below, but cannot get the value. Is it possible to grab it?

var $row = $(this).closest("tr"); 
$tds = $row.find("td");

Solution

You might use document.querySelector:

var input = document.querySelector('[name="value"]`);

Or, using jQuery, you could also use the same selector:

var input = $('[name="value"]');


Answered By - Matías Fidemraizer
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing