Anthony2oo4
08-28-2006, 10:14 PM
Hey, iv been working on this script, im not an expert with javascript i mainly code in php, but I cant get this script too work. I had it working at one point but the if statment didnt work, it always returned true for the first condition.
Any help would be great.
<script type="text/javascript">
<!--
/*<![CDATA[*/
function User() {
fm = document.useradmin;
choice = document.useradmin.choice.value;
user = document.useradmin.username.value;
if (choice == "edit") {
action="BHijkdfs767FGsdg.php?op=users&mode=edit&edit=profile&id="+user;
} else if (choice == "ban") {
action="BHijkdfs767FGsdg.php?op=users&mode=edit&edit=admin&id="+user;
} else if (choice == "posts") {
action="Forums/search/search_author="+user+".html";
} else if (choice == "pm") {
action="Private_Messages/mode=post/u="+user+".html";
} else if (choice == "profile") {
action="Your_Account/profile="+user+".html";
}
//document.write(action); I used these for debugging and commented out the last line but even that dosnt work, it just refreshs the page.
//document.write("<br>");
//document.write(choice);
fm.action=action;
}
/*]]>*/
// -->
</script>
<div align="center">
<form name="useradmin" method="POST" action="" onsubmit="User()">
<p style="margin-top: 0; margin-bottom: 0"><input type="text" name="username" size="20"></p>
<p style="margin-top: 0; margin-bottom: 0"><input type="radio" name="choice" value="edit" >Edit User</p>
<p style="margin-top: 0; margin-bottom: 0"><input type="radio" name="choice" value="ban">Ban User</p>
<p style="margin-top: 0; margin-bottom: 0"><input type="radio" name="choice" value="posts">View Posts</p>
<p style="margin-top: 0; margin-bottom: 0"><input type="radio" name="choice" value="pm">PM User</p>
<p style="margin-top: 0; margin-bottom: 0"><input type="radio" name="choice" value="profile">View Profile</p>
<p style="margin-top: 0; margin-bottom: 0"><input type="submit" value="Submit" name="B1"></td>
</form>
</div>
thanks for your time
Any help would be great.
<script type="text/javascript">
<!--
/*<![CDATA[*/
function User() {
fm = document.useradmin;
choice = document.useradmin.choice.value;
user = document.useradmin.username.value;
if (choice == "edit") {
action="BHijkdfs767FGsdg.php?op=users&mode=edit&edit=profile&id="+user;
} else if (choice == "ban") {
action="BHijkdfs767FGsdg.php?op=users&mode=edit&edit=admin&id="+user;
} else if (choice == "posts") {
action="Forums/search/search_author="+user+".html";
} else if (choice == "pm") {
action="Private_Messages/mode=post/u="+user+".html";
} else if (choice == "profile") {
action="Your_Account/profile="+user+".html";
}
//document.write(action); I used these for debugging and commented out the last line but even that dosnt work, it just refreshs the page.
//document.write("<br>");
//document.write(choice);
fm.action=action;
}
/*]]>*/
// -->
</script>
<div align="center">
<form name="useradmin" method="POST" action="" onsubmit="User()">
<p style="margin-top: 0; margin-bottom: 0"><input type="text" name="username" size="20"></p>
<p style="margin-top: 0; margin-bottom: 0"><input type="radio" name="choice" value="edit" >Edit User</p>
<p style="margin-top: 0; margin-bottom: 0"><input type="radio" name="choice" value="ban">Ban User</p>
<p style="margin-top: 0; margin-bottom: 0"><input type="radio" name="choice" value="posts">View Posts</p>
<p style="margin-top: 0; margin-bottom: 0"><input type="radio" name="choice" value="pm">PM User</p>
<p style="margin-top: 0; margin-bottom: 0"><input type="radio" name="choice" value="profile">View Profile</p>
<p style="margin-top: 0; margin-bottom: 0"><input type="submit" value="Submit" name="B1"></td>
</form>
</div>
thanks for your time