jquery - Filling input fields when pressing edit button -


I'm looking for a way through jQuery / Javascript to fill some input fields with data from a table I have seen this table:

  & lt; Tr & gt; & Lt; Th & gt; TicketID & lt; / Th & gt; & Lt; Th & gt; EventID & lt; / Th & gt; & Lt; Th & gt; Name & lt; / Th & gt; & Lt; Th & gt; Price & lt; / Th & gt; & Lt; Th & gt; PriceWithinAllocation & lt; / Th & gt; & Lt; Th & gt; & Nbsp; & Lt; / Th & gt; & Lt; / TR & gt; & Lt; Tr & gt; & Lt; Td square = "ticket id" & gt; 1 & lt; / Td> & Lt; Td class = "event id" & gt; 1 & lt; / Td> & Lt; Td class = "name" & gt; Sun & lt; / Td> & Lt; Td square = "value" & gt; 300 & lt; / Td> TD class = "price wothline allocation" & gt; 150 & lt; / Td> & Lt; Td align = "center" & gt; & Lt; Input type = "button" class = "editRow" value = "edit" /> gt; & Lt; / Td> & Lt; / TR & gt; & Lt; Tr & gt; & Lt; Td square = "ticket id" & gt; 2 & lt; / Td> & Lt; Td class = "event id" & gt; 1 & lt; / Td> & Lt; Td class = "name" & gt; Mon & lt; / Td> & Lt; Td square = "value" & gt; 300 & lt; / Td> & Lt; Td class = "price alignment" & gt; 150 & lt; / Td> & Lt; Td align = "center" & gt; & Lt; Input type = "button" class = "editRow" value = "edit" /> gt; & Lt; / Td> & Lt; / TR & gt;   

I also have a form that I want to show the value inside. However, not all values ​​should be seen there.

  & lt; P & gt; & Lt; Label = "" & gt; Name: & lt; / Label & gt; & Lt; Input type = "text" name = "name" /> & Lt; / P & gt; & Lt; P & gt; & Lt; Label = "" & gt; Price: & lt; / Labels & gt; & Lt; Input type = "text" name = "value" /> & Lt; / P & gt; & Lt; P & gt; & Lt; For label = "" & gt; Price Inductance: & lt; / Labels & gt; & Lt; Input type = "text" name = "value activation" />   

So, say, I click on the edit button of the first line, I'll call name , value and pricewithinallocation However, I have no way to do this to appear in my input field. I tried with some jquery DOM Travelers but it did not work out properly. Anyone can see a solution here? Is this also possible?

  & lt; / P & gt; & Lt; P & gt; & Lt; Input type = "submit" id = "saveNew" value = "SAVE" /> & Lt; Input type = "button" id = "cancelNew" value = "CANCEL" />    

Try it out:

  $ (function ( ) {$ (". EditRow") (function () {var name = $ (this) .Parent (). Sister (".name"). Text (); var value = $ (this) .Parent Sibling (". Value"). Text (); var priceAthocation = $ (this) .part (). Siblings ("with value value"). Text (); $ ("[name = 'name '] ") .val (name); $ (" [name =' price '] "). Val (price); $ (" [name =' priceWithinAllocation '] "). Val (priceWithinAllocation);}); ); Example:  

Optional:

  $ (function () {$ (". EditRow"). Click (function () ($ ("[Name = 'name '] "). Val ($ (this) .Parent (). Sister (" .name "). Text ()); $ (" [name =' price '] "($ (This) .value ($ (This) .Parent (). Sister (". Value"). Text ()); $ ("[name = 'priceWithinAllocation']"). Val ($ (this) .Parent () .siblings (" Value value "). Text ());});})    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

c# - Client template not working with custom helper action methods -