I'm using classic asp. I have a form which is filled up by images taken from a db and other type of inputs. If the user clicks on one image, I need to add an item (maybe a string, maybe a number, it's not relevant) to an array and then send it to a classic asp page with all the other values in the form. My code is something like this: (in this case the array is filled by clicking a button)
<script language ="javascript">
var arr = [];
var i = 0;
function aggiungi() {
arr.push(i.toString());
i++;
}
</script>
<html>
<form method ="post" action="save.asp">
<input type ="text" name="nome" />
<input type ="button" onclick="aggiungi()" value ="add"/>
<input type="submit" value ="invia" />
</form>
I wanna send the value in the textbox and the array arr. How can I do?
Along the lines of what @stephen-r was saying, this appears to be a HTML form question, not really ASP.
If the HTML Form elements have the same name, then they'll come through on the receiving page as a comma separated list. Meaning that his solution would do precisely what he says.
Where it becomes an ASP question is on the receiving page.
Personally, If I were going to use the button idea as you've described, I would probably have hidden checkboxes and use client-side JavaScript to check/uncheck them as the button (or image) is pressed.
Alternatively, if you'd like to do more work, have one hidden textbox, and use client-side JavaScript to add/remove the the contents of that textbox based on what has been pushed. (using a comma as a delimiter.)
!! Either way, the ASP page receiving the form will be seeing a comma separated list of values.