morne
morne

Reputation: 4189

Get value of input with a variable id using jQuery

Im trying to get the value of a selected object in a table.

the id's are auto generated like to resemble this

( status1, status2, status3....)

I use the following to extract the row id

var $row = this.id.match(/\d+/); // Extract number to get row id

and then I want to concatenate that row id to get the value of the column, like this

var $hasID = $("hasid"+$row).val();

but $hasID remains UNDEFINED

Upvotes: 0

Views: 562

Answers (1)

Satpal
Satpal

Reputation: 133453

Prefix # when using ID selector. Since match will return you an array use [0] to get first element.

Use

var $hasID = $("#hasid" + $row[0]).val();

Upvotes: 3

Related Questions