Forum Moderators: open
please see the following code,
Code:
for (var i=0; i<spn.length; i++) {
f[i].value = res[i+1];
checkHistory(res[i+1])
//alert (res[i+1])
spn[i].innerHTML = res[i+1];
}
this loop runs four times for four keywords and the checkHistory() reads PHP session array and searches if any keyword is already present in the SESSION. If present then it reads its relative suggestion from the mySQL DB and displays it.
now the problem is that if the visitor has seen suggestion for fourth keyword that is the last keyword of the loop then it displays the suggestion in the DIV properly but if the user has seen suggestion for any keyword except fourth that is the last one then it doesnt show it.
if i comment ALERT it does not show it, BUT if i un-comment ALERT it does display it. I am lost that what it has to do with ALERT.. can you shed some light on this please?
thanks
'res' is an array that i get back from AJAX function response.
spn is an array of radio buttons. the four keywords have on radio button in front of each that radio button value is assigned in this loop. as i fetch keywords from DB so i assign them to radio buttons one by one in the loop at the same time i call a function checkHistory() to see if any of keyword is present in current session of the user if it is it means user has seen its response before so i will automatically display its response too so that user can see what keywords' response he has seen before in the current session.
i hope it makes more sense now..
the wierd problem is that if i place the ALERT before checkHistory() function then it workes in the desired way. But if i remove ALERT from there then it doesn't call the ShowRec function even it founds the keyword in the session array...
i am just lost that what alert has to do with it and how can i fix it?
pls help i am just lost..
when i place ALERT in my previous shown code then it does also show the ALERT of checkHistory() body but if i comment ALERT in my previously shown code it also doesn't call checkHistory() body ALERT, it means that code does found keyword in the session but at the same time it doesn't call checkHistory()...
how can i solve this?