0

I need to add an @Html.HiddenFor when a button is clicked

My jquery code is this:

function btnAdd() {

var x;
y = $("#drpDwnPRTPP");  

$("#budgetsList ul").html('<li>Primer elemento ' +
'@Html.HiddenFor(x => Model.ToList()['+ c +'].PRTPP_ID, new { @id="prtppID"'+ c +', @value="'+ y.val() +'" })' +
'</li>'
   ); 
}

But when i clicked this is what i get in my html :

Primer elemento @Html.HiddenFor(x => Model.ToList()[0].PRTPP_ID, new { @id="prtppID"0, @value="1" })

instead an input element

any way to do this ? ? ...

Lio
  • 5
  • 1
  • 3
  • 5

1 Answers1

3

HTML helpers are server side, Jquery is happening on the client side, so you are going to need to add your hidden field on the client side. See: stackoverflow

Community
  • 1
  • 1
Maess
  • 4,118
  • 20
  • 29
  • yep, i dont why i ask this,is the hunger that i have, doesnt let me think clearly haha – Lio Sep 05 '12 at 19:36