Forum Moderators: open
var score = document.edit_cup.score_1_1.value;
var score = document.["edit_cup"].score_1_1.value;
But for me the first one works and the second one just causes none of the javascript on my page to work.
The reason i ask this is i have the below javascript code (The webpage is created by php via echo, hence the escaping of the double quotes):
function submitCupDetails(cup_id, match_count) {
var form = document.createElement('form');
form.setAttribute('method', 'post'); //submit each score field, regardless of enty or not
for(var i=0; i<match_count; i++) {
for(var j=1; j<=2; j++) {
var score = document.edit_cup.[\"score_\" + i + \"_\" + j].value;
var hiddenField = document.createElement('input');
hiddenField.setAttribute('type', 'hidden');
hiddenField.setAttribute('name', \"score_\" + i + \"_\" + j);
hiddenField.setAttribute('value', score);
form.appendChild(hiddenField);
}
}
//submit the form so that the page reloads the new data
document.body.appendChild(form);
form.submit();
}
I have around 40 text fields each labelled in pairs with the names of 'score_0_1', 'score_0_2', 'score_1_1', 'score_1_2', 'score_2_1', ect and i am needing to get the values of each to submit.