So I have a few inputs with the name session and they increment.... session0 session1 session2. If I want to run them through a loop how would I do that. I'm using jquery.
for example..
for(i=0,i<10,i++)
{
var num = (session + i).value + i;
}
So what I want is the loop to go through all the inputs with prefix session and output their values to a variable. This out put could go into a array. if array obviously would look more like.
num[i] = stuff+i;
thanks.
Okay well I ended up going with the JavaScript. Thanks for all the help it works great. here was the final code.
function get()
{
var alldata;
var values = [];
$("input[name^='media']").each(function(i, anInput) {
var check = values[i] = $(anInput).attr('checked');
if(check == true)
{
var ID = "session" + i;
var type = $(anInput).attr('value');
if(i > 9)
{
var cont = "#ex"+ i;
}
else{
var cont = "select[name='" + ID + "']";
}
var scope = $(cont).attr('value');
if(!alldata)
{
alldata = type + ': ' + scope + ' ';
}
else
alldata = alldata + ' ' + type + ': ' + scope + ' ';
};
})
$('#sessions').attr('value',alldata);
}