JRockFL
asked on
Adding multiple rows dynamically and persisting to database
A product row can be added by clicking the Add Row link.
This will add a new row with the ddSlick select.
When a user adds new rows, I need to be able to persist the values to the database.
The onSelected event fires, and now I just have an alert
alert(data.selectedData.va lue)
I can use the onSelected event to set the value to a hidden field, but will that cause me issues if the user adds more than 1 row?
Am I going about this the wrong way?
http://jsfiddle.net/xarPG/4/
This will add a new row with the ddSlick select.
When a user adds new rows, I need to be able to persist the values to the database.
The onSelected event fires, and now I just have an alert
alert(data.selectedData.va
I can use the onSelected event to set the value to a hidden field, but will that cause me issues if the user adds more than 1 row?
Am I going about this the wrong way?
http://jsfiddle.net/xarPG/4/
ASKER
Thank you for the reply.
When I try to access it on the server side
Request.Form("products") = null
Request.Form("products[]") = ","
Am I doing this right?
<input type='hidden' name='products[]' id='products[]' />
$('#products').val(data.se lectedData .value);
When I try to access it on the server side
Request.Form("products") = null
Request.Form("products[]")
Am I doing this right?
<input type='hidden' name='products[]' id='products[]' />
$('#products').val(data.se
don't use this for ID, ID atribute value MUST BE unique in a document
hope you're talking about .Net :
http://stackoverflow.com/questions/2776711/passing-array-values-in-an-http-request-in-net
hope you're talking about .Net :
http://stackoverflow.com/questions/2776711/passing-array-values-in-an-http-request-in-net
ASKER
I have updated the way in which the hidden field's value is set. Yes. I'm using .net
Results:
?Split(Request.Form("produ cts"), ",")
{Length=2}
(0): "11"
(1): "11"
When I use this name, no values are saved.
Results:
?Split(Request.Form("produ cts"), ",")
{Length=1}
(0): ""
$('input[name=products]').val(data.selectedData.value);
<input type='hidden' name='products' />
I added two rows with two different products. When I do it this way, there are two values but they are both the same when it should be different.Results:
?Split(Request.Form("produ
{Length=2}
(0): "11"
(1): "11"
When I use this name, no values are saved.
Results:
<input type='hidden' name='products[]' />
?Split(Request.Form("produ
{Length=1}
(0): ""
Not sure where, how you put this line
$('input[name=products]'). val(data.s electedDat a.value);
So randomly I can propose :
$(this).closest("tr").find ('input[na me=product s]').val(d ata.select edData.val ue);
OR :
$(this).find('input[name=p roducts]') .val(data. selectedDa ta.value);
Please update the jsfiddle IF YOU TRIED and it don't work, thanks
$('input[name=products]').
So randomly I can propose :
$(this).closest("tr").find
OR :
$(this).find('input[name=p
Please update the jsfiddle IF YOU TRIED and it don't work, thanks
ASKER
Still not working.
I have update jsfiddle
http://jsfiddle.net/xarPG/ 10/
1. Add a new row. (The value of the id will be set to the quantity textbox to easily see value)
2. Add a second row.
3. Change the value of the second row. The first value is also updated. This is the problem.
I have update jsfiddle
http://jsfiddle.net/xarPG/
1. Add a new row. (The value of the id will be set to the quantity textbox to easily see value)
2. Add a second row.
3. Change the value of the second row. The first value is also updated. This is the problem.
where did you put the code provided ID 38866191?
I can't locate it
I can't locate it
ASKER
I took it out, it was above updaterows
please put it at the same position when you said it don't work.
ASKER
I have updated fiddle, line 45.
I also changed the code to display the value in quantity textbox instead of hidden field so I could see results.
I also changed the code to display the value in quantity textbox instead of hidden field so I could see results.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You are awesome!
That did it :)
Thank you so much for your dedicated help with this.
That did it :)
Thank you so much for your dedicated help with this.
Open in new window
Create an array (add [] to each hidden field's name)
<input type="hidden" name="ddSlick[]" />
<input type="hidden" name="ddSlick[]" />
<input type="hidden" name="ddSlick[]" />
on the server side you get an array for the parameter ddSlick