Hello. I'm not so good at Javascript, but I tried to write some code to obtain some form values and write those to a query string to use in AJAX.
It seems to be working partially, but I don't understand what is going wrong. What happens is that in the for loop the 'document.form_name.form_field_names_array.value' part doesn't seem to return a value. It is worse even: the script completely stops executing at that part. When I remove that part from the line in the for loop, it doesn't stop executing, so I guess that's where the problem is?
function doAjaxForm(url, target_element_id, img_url, form_name, form_field_names)
{
// Create the GET query string from the form_fields
form_field_names_array = form_field_names.split(',');
for(i=0; i<form_field_names_array.length; i++)
{
if(i==0)
{
query_string = form_field_names_array[i] + '=' + document.form_name.form_field_names_array[i].value;
}
else
{
query_string += form_field_names_array[i] + '=' + document.form_name.form_field_names_array[i].value;
}
}
// Result: something like query_string = field1=value1&field2=value2&etc...
// Rest of the code (the AJAX) is working.