Nightrider
11-04-2007, 04:24 AM
I'm trying to code a Resume utility for a friend using php, MySql, and html through phpBB, but I am fighting some strange problems that don't make sense to me. This is my code:
function cat_select(cat_index)
{
var txtarea = document.main.transportation;
var salaray = document.main.salary_range_select;
var relocate = document.getElementById("main_relocate");
var travel = document.getElementById("main_travel");
var resume_list = "{RESUME_LIST}";
var resume_list_array = resume_list.split('@');
//Reset the fields
salaray.selectedIndex = 0;
relocate.checked = 2;
travel.checked = 2;
txtarea.value = '';
for (i=0;i<resume_list_array.length;i++)
{
var next_record = resume_list_array[i];
var resumes_array = next_record.split("|");
if (resumes_array[0] = cat_index)
{
salaray.selectedIndex = parseInt(resumes_array[1]);
relocate.checked = parseInt(resumes_array[2]);
travel.checked = parseInt(resumes_array[3]);
txtarea.value = resume_list_array[i];
return;
}
}
return;
}
The following is what is assigned to {RESUME_LIST}
10|9|1|0|plane, car@21|0|2|2|@89|7|0|0|Car@93|10|1|1|plane, car
Once this is split, based on the @ character, it should be assigned to an array with the following values, which appears to be working correctly:
10|9|1|0|plane, car
21|0|2|2|
89|7|0|0|Car
93|10|1|1|plane, car
Then I split this on "|" to retrieve 5 sub array items, which also initially seems to be working correctly. The following seems to correctly compare the first item in the sub array (89) to the cat_index value:
if (resumes_array[0] = cat_index)
But once inside the if statement, the matched value in the resume_list_array[i] item is wrong. IOW, when I match on the cat_index 89, the value assigned to resume_list_array[i] seems to be "10|9|1|0|plane, car" rather than "89|7|0|0|Car" like I would expect. All the items in the resumes_array[1-4] array are assigned incorrectly at that point as well...
Why wouldn't the value assigned in resume_list_array[i] be "89|7|0|0|Car" once I match resumes_array[0] = cat_index???
Also, I have a an object with 3 radio buttons assigned 0,1,2, representing yes, no, and maybe. I can set the radio check to 1 (yes), but I can't get it assigned to 0 (no) or 2 (maybe). I tried using both the following with no success:
travel.checked = 0
travel.value = 0
Thanks in advance...
http://img398.imageshack.us/img398/3663/dontknow6sf.gif
function cat_select(cat_index)
{
var txtarea = document.main.transportation;
var salaray = document.main.salary_range_select;
var relocate = document.getElementById("main_relocate");
var travel = document.getElementById("main_travel");
var resume_list = "{RESUME_LIST}";
var resume_list_array = resume_list.split('@');
//Reset the fields
salaray.selectedIndex = 0;
relocate.checked = 2;
travel.checked = 2;
txtarea.value = '';
for (i=0;i<resume_list_array.length;i++)
{
var next_record = resume_list_array[i];
var resumes_array = next_record.split("|");
if (resumes_array[0] = cat_index)
{
salaray.selectedIndex = parseInt(resumes_array[1]);
relocate.checked = parseInt(resumes_array[2]);
travel.checked = parseInt(resumes_array[3]);
txtarea.value = resume_list_array[i];
return;
}
}
return;
}
The following is what is assigned to {RESUME_LIST}
10|9|1|0|plane, car@21|0|2|2|@89|7|0|0|Car@93|10|1|1|plane, car
Once this is split, based on the @ character, it should be assigned to an array with the following values, which appears to be working correctly:
10|9|1|0|plane, car
21|0|2|2|
89|7|0|0|Car
93|10|1|1|plane, car
Then I split this on "|" to retrieve 5 sub array items, which also initially seems to be working correctly. The following seems to correctly compare the first item in the sub array (89) to the cat_index value:
if (resumes_array[0] = cat_index)
But once inside the if statement, the matched value in the resume_list_array[i] item is wrong. IOW, when I match on the cat_index 89, the value assigned to resume_list_array[i] seems to be "10|9|1|0|plane, car" rather than "89|7|0|0|Car" like I would expect. All the items in the resumes_array[1-4] array are assigned incorrectly at that point as well...
Why wouldn't the value assigned in resume_list_array[i] be "89|7|0|0|Car" once I match resumes_array[0] = cat_index???
Also, I have a an object with 3 radio buttons assigned 0,1,2, representing yes, no, and maybe. I can set the radio check to 1 (yes), but I can't get it assigned to 0 (no) or 2 (maybe). I tried using both the following with no success:
travel.checked = 0
travel.value = 0
Thanks in advance...
http://img398.imageshack.us/img398/3663/dontknow6sf.gif