Hi I was trying to access form input values but the field names are dynamic and I couldn't make it work Any help would be extremely appreciated This is the function that is not working function SaveRating(resourceId,order_id) { var r1="response"+resourceId; var s1="schedule"+resourceId; var a1="accurate"+resourceId; var r=document.form1.r1.value; var s=document.form1.s1.value; var a=document.form1.a1.value; var url="orderDetail.php?resourceId="+resourceId+"&r="+r+"&s="+s+"&a="+a+"&order_id="+order_id+"&rate=1"; window.location.href=url; } Code (markup):
if r1 is your input id, you should try this instead var r1="response"+resourceId; var r=document.getElementById(r1).value; Code (markup):
This will do javascript:arr = [];x = 0; for(i in (d = document.forms[0].elements)){ arr[x] = d.value;x+=1 } alert(arr.join("\n"))