exploit
06-28-2012, 10:37 PM
Hi All,
Im new here, im not very good at JS and mainly do PHP however i have needed to make a quick script however im not very good at it.
I am sending a string to permission_groups then spliting this into 4 arrays in JS. when the alert for number comes up it counts correctly 0,1,2,3. I am putting this as the array value to get array text 0,1,2 and 3 however only when it runs the first time and uses 0 it works fine but when it runs the following times i get only the first letter of the array's in the fields "group[number]". I get the following "<option value='o'>o</option>" then the next alert will be "<option value='t'>t</option>" when it should be "<option value='Manager'>Manager</option>". If i do an alert for "group[3]" it works fine and gives me the full text. :S
<script type="text/javascript">
function changefield(unique_id,userid,active,f_name,l_name,contact_n,contact_e,permission_group_name, permission_groups){
var group=permission_groups.split("_");
//alert(group[2]);
count = group.length;
count--;
number = 0;
while (count>0){
group = "<option value='"+group[number]+"'>"+group[number]+"</option>";
count--;
alert(number);
alert(group);
number++;
}
document.getElementById(unique_id+"user_id").innerHTML = "<input id=\"user_id\" type=\"text\" name='"+unique_id+"_user_id"+"' value='"+userid+"' />";
document.getElementById(unique_id+"active").innerHTML = "<input id=\"active\" type=\"text\" name='"+unique_id+"_active"+"' value='"+active+"' />";
document.getElementById(unique_id+"f_name").innerHTML = "<input id=\"f_name\" type=\"text\" name='"+unique_id+"_f_name"+"' value='"+f_name+"' />";
document.getElementById(unique_id+"l_name").innerHTML = "<input id=\"l_name\" type=\"text\" name='"+unique_id+"_l_name"+"' value='"+l_name+"' />";
document.getElementById(unique_id+"contact_n").innerHTML = "<input id=\"contact_n\" type=\"text\" name='"+unique_id+"_contact_n"+"' value='"+contact_n+"' />";
document.getElementById(unique_id+"contact_e").innerHTML = "<input id=\"contact_e\" type=\"text\" name='"+unique_id+"_contact_e"+"' value='"+contact_e+"' />";
document.getElementById(unique_id+"permission_group_name").innerHTML = "<select name='"+unique_id+"_permission_group_name"+"'>"+group+"<option value='blblb2'>permission set 2</option></select>";
} // End function changefield
</script>
Im new here, im not very good at JS and mainly do PHP however i have needed to make a quick script however im not very good at it.
I am sending a string to permission_groups then spliting this into 4 arrays in JS. when the alert for number comes up it counts correctly 0,1,2,3. I am putting this as the array value to get array text 0,1,2 and 3 however only when it runs the first time and uses 0 it works fine but when it runs the following times i get only the first letter of the array's in the fields "group[number]". I get the following "<option value='o'>o</option>" then the next alert will be "<option value='t'>t</option>" when it should be "<option value='Manager'>Manager</option>". If i do an alert for "group[3]" it works fine and gives me the full text. :S
<script type="text/javascript">
function changefield(unique_id,userid,active,f_name,l_name,contact_n,contact_e,permission_group_name, permission_groups){
var group=permission_groups.split("_");
//alert(group[2]);
count = group.length;
count--;
number = 0;
while (count>0){
group = "<option value='"+group[number]+"'>"+group[number]+"</option>";
count--;
alert(number);
alert(group);
number++;
}
document.getElementById(unique_id+"user_id").innerHTML = "<input id=\"user_id\" type=\"text\" name='"+unique_id+"_user_id"+"' value='"+userid+"' />";
document.getElementById(unique_id+"active").innerHTML = "<input id=\"active\" type=\"text\" name='"+unique_id+"_active"+"' value='"+active+"' />";
document.getElementById(unique_id+"f_name").innerHTML = "<input id=\"f_name\" type=\"text\" name='"+unique_id+"_f_name"+"' value='"+f_name+"' />";
document.getElementById(unique_id+"l_name").innerHTML = "<input id=\"l_name\" type=\"text\" name='"+unique_id+"_l_name"+"' value='"+l_name+"' />";
document.getElementById(unique_id+"contact_n").innerHTML = "<input id=\"contact_n\" type=\"text\" name='"+unique_id+"_contact_n"+"' value='"+contact_n+"' />";
document.getElementById(unique_id+"contact_e").innerHTML = "<input id=\"contact_e\" type=\"text\" name='"+unique_id+"_contact_e"+"' value='"+contact_e+"' />";
document.getElementById(unique_id+"permission_group_name").innerHTML = "<select name='"+unique_id+"_permission_group_name"+"'>"+group+"<option value='blblb2'>permission set 2</option></select>";
} // End function changefield
</script>