Hey everyone, I am posting this topic as I have this recurring error with javascript and I cannot for the life of me figure out what is wrong with it. I am creating my own forums and this error happens when you are viewing a topic.
I have an option box at the bottom of each post for options e.g. post creator to edit their post and for users to report posts. I am not using a button to jump from the option box to a link but instead I am using javascript. The first post always works fine then the second one works but after there is more than 1 reply only the first post works. I use two different javascript parts as shown.
Here is two sections of the view topic code, one for the first post and one for all other posts.
<form name="firstpost">
<select name="fp_mod" size="1" onchange="fp_mod_gone()">
<option value="">Post Options :</option>
<option value="">--------------------</option>
<? if($session->username == $fp_poster || $session->isNewMod()){ ?>
<option value="editpost.php?post=<? echo "$fp_postid"; ?>">Edit Post</option>
<option value="">--------------------</option>
<? } ?>
Here is the section for all other posts, this part uses mysql_fetch_array to display the same for each different post.
<form name="otherposts">
<select name="op_mod" size="1" onchange="op_mod_gone()">
<option value="">Post Options :</option>
<option value="">--------------------</option>
<? if($session->username == $op_poster || $session->isNewMod()){ ?>
<option value="editpost.php?post=<? echo "$op_postid"; ?>">Edit Post</option>
<option value="">--------------------</option>
<? } ?>
Here are the javascript functions,
function op_mod_gone()
{
location=document.otherposts.op_mod.options[document.otherposts.op_mod.selectedIndex].value
}
function fp_mod_gone()
{
location=document.firstpost.fp_mod.options[document.firstpost.fp_mod.selectedIndex].value
}
The first post always works then with one reply the second post and the first post work. But with more than one reply I get this error:
document.otherposts.op_mod is undefined
location=document.otherposts.op_mod.opt...t.otherposts.op_mod.selectedIndex].value
Anyone got any ideas, Thanks in advanced.
Dj.