tags:

views:

43

answers:

2

Hi, I have a View where some input text to be added dynamica using jquery, I mean everything funzona, and when I go to add these inputs and do right button on the browser I'm not seeing the added input.

function addPerson () (

current + +; 

StrToAdd var = '<table id="compo" name="compo"' + current +'> <tr> <td> <label for="firstname"' + current +'"> Name </ label> <input id = 'firstname' + current + '"name =" Componenti.Nome_ "' +" "+ current +" "+ '" size = "29" /> </ td> <td> <label for = "lastname"' current + + '"> Name </ label> <input id="lastname''" name="Componenti.Cognome_"' + + + current + current'" size="29" /> </ td>' 

StrToAdd + = '<td> <label for="luogonascita"' + current +'"> LuogoNascita </ label> <input id = "luogodinascita' + current + '" name = "Componenti.Luogonascita_"' + "" + current + "" + '"size =" 29 "/> </ td>' 

StrToAdd + = '<td> <label for="datanascita"' + current +'"> DataNacita </ label> <input id = "dateOfBirth' + current + '" name = "Componenti.datanascita_"' + current + ' "size =" 29 "/> </ td> </ tr> </ table> ' 

StrToAdd + = '<script type="text/javascript"> jQuery (function ($) {$("# dateOfBirth' + current + '). mask ("' + mask +'")});</ script > '; 

$ ('# Components'). Append (StrToAdd); 

)

The problem is that when I pass the data via post in the action, and I go to create the education

var valueProvider= formanagrafica.ToValueProvider();

valueProvider I find all the input I have added only one and that therefore there are more than one gives me the values separated by commas.

How can I retrieve the values of a line of input text? I hope I explained correctly.

A: 

You need to have the name attribute for each element to be included in the formcollection. If you have two identical name on different elements, the values will be comma separated at post. All unique names will have their associated values with them.

Example 1

<input name="foo" value="hi">
<input name="foo" value="there">

FormCollection would have one key called "foo" and the value would be "hi,there"

Example 2

<input name="foo1" value="hi">
<input name="foo2" value="there">

FormCollection would have two keys one called "foo1" with the value of "hi" and the second key called "foo2" with the value of "there"

Javascript issue?

I see current + +; at the top of your function call... what is it inialized to? Maybe change it first off to current++; and then after that for debugging sake have alert(current); to see what the value after your increment, to make sure this thing is working correctly.

gmcalab
But excuse when I am writing this in jquery:"Componenti.Luogonascita_" '+ "" + current + "" +the current variable should not be one that creates a united?how else can I do? Thanks again
well if you are dynamic creating the input fields and using a unique number that you are appending on the end of the name, that will work. What does your view source look like after the page is rendered...before you submit. make sure the names are unique (current)....you might have a simple javascript error here...Look at my answer edit about double checking the 'current' value on each call.
gmcalab
A: 

You were right, the error was in the creation and input coe went to add a double quote and saw the current double quotes, it is now alright.

Thanks