Sleep Paralysis Sleep Paralysis -4 years ago 112
C# Question

Populate array in Jquery and pass to controller

I have a simple C# program where a user enters the ID of a item to be discarded then the individual who is to take it away signs and does so.
Upon entering the ID, you click the "search" button, the purpose of that button is to ensure that such an item exist in the database.


This method works however,, if there are 50 items to discard, my program requires the individual to sign 50 times. I am trying to have it so that, when I enter the ID number I can keep adding then ask for a signature once that will cover all 50 items.

My question is, I am having some issue with constantly adding the ID number to my textbox. In my jquery I have the line

document.getElementById('test').value = document.getElementById('refno').value;

which takes the value from the refno textbox and adds it to the test texbox. Obviously that simple replaces the value and I am not sure of how to append it. So my next bet is an array. My question therefore is, how do I when I click the "Add" button, store those value in an array and then pass it to my controller and at the same time display it on the UI so that it can be edited ie if an id was entered in error.

Answer Source

This should add the value instead of replace it:

document.getElementById('test').value += document.getElementById('refno').value + ';';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download