Jump to content

help with website coding


stathis

Recommended Posts

Hello everyone. First of all let me start by saying that i'm not a coder but a website owner.

 

I have this piece of code in my website that a hired coder did and used to work with older browsers but not any more. Old browsers meaning that it used to work with IE8 but not with current IE nor Chrome.

 

So essentially what i was doing was when i selected a player from the dropdown list and pressed "Rename" button, i was presented with a popup windows to rename the player, and if a player with the same name existed to merge his stats.

 

Now, when i press the "Rename" button the page refreshes without getting any popups and player is no longer in the list as if it was deleted from the database.

 

Can anyone help me to solve this?

 

I'm also attaching the whole file if it can be of any help.

<FORM method=post action="admin_league.php?id=<?=$leagueid?>&s=<?= $seasonid ?>&rplayer=1" onSubmit="return renamePlayer()">Current Players: <SELECT name=currPlayer><OPTION value=0>              <?php  $r = mysql_query("SELECT id, name FROM players WHERE season=$seasonid ORDER BY name");  $names = array();  while (list($id, $name) = mysql_fetch_row($r)) {    echo("<OPTION value=$id>$namen");    $names[] = preg_quote($name, "/");  }  $regexp = "/^" . join("$|^", $names) . "$/";?></SELECT><INPUT type=hidden name="newPlayerName"><INPUT type=submit value="Rename"></FORM></DIV><SCRIPT language=javascript>  var cpDropdown = document.getElementById('currPlayer');  var nnHidden = document.getElementById('newPlayerName');  function renamePlayer() {    var cpOption = cpDropdown.options[cpDropdown.selectedIndex];    id=cpOption.value;    oldname=cpOption.text;    if (id==0) {      alert("You must select a player to rename first.");      return false;    }    newname = prompt("Please enter a new name for '"+oldname+"':", oldname);    if (!newname || newname==oldname) {      return false;    }    if (new String(newname).search(<?= $regexp ?>) != -1) {      if (!confirm("The name "+newname+" already exists.nWould you like to combine "+oldname+"'s stats into "+newname+"'s?"))        return false;    }    nnHidden.value = newname;    return true;  }</SCRIPT>

admin_league.zip

Link to comment
Share on other sites

Since people are here can i get some help?

Ive been trying to get this code to work but i cant.

If someone could just go and rewrite it so it will work i will be so happy since this is due tomorrow

 

 

var Room = promt(“Which Room Are You Looking For”?);

if {

Room = [113, 111, 115, 117, 205, 211, 215, 217, 309, 313, 311, 315, 317, 321]

console.log(“The Staircase Closest To Your Room Is Staircase A”)

};

if {

Room = [107, Main Office, 207, 213, 202, Library, 202, 307, 205, 303]

console.log(“The Staircase Closest To Your Room Is Staircase B”)

};

if {

Room = [106, 104, 110, 206, 212, 210, 310, 308]

console.log(“The Staircase Closest To Your Room Is Staircase C”)

};

if {

Room = [112, Weight Room, Boys Locker Room, 114A, Gym 1, PE Office, Trainer Athletic Director, 312, Gym 1 Balcony, Gym 2]

console.log(“The Staircase Closest To Your Room Is Staircase D”)

};

if {

Room = [114, Clinic, 118, Girls Locker Room, Swimming Pool, 120, 214, 220, 218, 214, 314, 316, 318, 320]

console.log(“The Staircase Closest To Your Room Is Staircase G”)

};

if {

Room = [136, 134, 122, 132, 140, 222, 224, 234, 236, 238, 240, 322, 334, 324, 322A, 336, 338, 340, 342]

console.log(“The Staircase Closest To Your Room Is Staircase H”)

};

if {

Room = [138, 144, 146, 150, 154, 148, 242, 244, 246, 248, 250, 252, 254, 258, 260, 256, 344, 346A, 346, 348, 350, 356, 360, 358, 354, 352]

console.log(“The Staircase Closest To Your Room Is Staircase J”)

};

if {

Room = [161, 149, 147, 145, 151, 153, 157, 155, 153A, 251, 249 247, 257A, 257, 253, 255, 261, 259, 353, 351, 349 Gym 3]

console.log(“The Staircase Closest To Your Room Is Staircase M”)

if {

Room = [ 143, 141, 125, 119, 123, 127, 139, 137, 243,241, 225, 221, 223, 239, 229, 345, 347, 343, 341B, 341, 339, 329, 327, 325, 323, 325]

console.log(“The Staircase Closest To Your Room Is Staircase O”)

if {

Room = [129, 135, 133, 130, 128, 231, 235, 233, 230, 228, 232, 226, 331, 337, 333, 335, 330, 328, 332R, 326, 332]

console.log(“The Staircase Closest To Your Room Is Staircase Z”)

};

 

Link to comment
Share on other sites

Since people are here can i get some help?

Ive been trying to get this code to work but i cant.

If someone could just go and rewrite it so it will work i will be so happy since this is due tomorrow

 

 

var Room = promt(“Which Room Are You Looking For”?);

if {

Room = [113, 111, 115, 117, 205, 211, 215, 217, 309, 313, 311, 315, 317, 321]

console.log(“The Staircase Closest To Your Room Is Staircase A”)

};

if {

Room = [107, Main Office, 207, 213, 202, Library, 202, 307, 205, 303]

console.log(“The Staircase Closest To Your Room Is Staircase B”)

};

if {

Room = [106, 104, 110, 206, 212, 210, 310, 308]

console.log(“The Staircase Closest To Your Room Is Staircase C”)

};

if {

Room = [112, Weight Room, Boys Locker Room, 114A, Gym 1, PE Office, Trainer Athletic Director, 312, Gym 1 Balcony, Gym 2]

console.log(“The Staircase Closest To Your Room Is Staircase D”)

};

if {

Room = [114, Clinic, 118, Girls Locker Room, Swimming Pool, 120, 214, 220, 218, 214, 314, 316, 318, 320]

console.log(“The Staircase Closest To Your Room Is Staircase G”)

};

if {

Room = [136, 134, 122, 132, 140, 222, 224, 234, 236, 238, 240, 322, 334, 324, 322A, 336, 338, 340, 342]

console.log(“The Staircase Closest To Your Room Is Staircase H”)

};

if {

Room = [138, 144, 146, 150, 154, 148, 242, 244, 246, 248, 250, 252, 254, 258, 260, 256, 344, 346A, 346, 348, 350, 356, 360, 358, 354, 352]

console.log(“The Staircase Closest To Your Room Is Staircase J”)

};

if {

Room = [161, 149, 147, 145, 151, 153, 157, 155, 153A, 251, 249 247, 257A, 257, 253, 255, 261, 259, 353, 351, 349 Gym 3]

console.log(“The Staircase Closest To Your Room Is Staircase M”)

if {

Room = [ 143, 141, 125, 119, 123, 127, 139, 137, 243,241, 225, 221, 223, 239, 229, 345, 347, 343, 341B, 341, 339, 329, 327, 325, 323, 325]

console.log(“The Staircase Closest To Your Room Is Staircase O”)

if {

Room = [129, 135, 133, 130, 128, 231, 235, 233, 230, 228, 232, 226, 331, 337, 333, 335, 330, 328, 332R, 326, 332]

console.log(“The Staircase Closest To Your Room Is Staircase Z”)

};

 

Link to comment
Share on other sites

I don't write code for people (at least not without a salary), I'm here to help people learn. It seems you need to learn the basic syntax of a conditional

 

You need to learn about comparisons, the if() statement and the logical operators:

 

http://www.w3schools.com/js/js_comparisons.asp

http://www.w3schools.com/js/js_if_else.asp

http://www.w3schools.com/js/js_operators.asp

  • Like 1
Link to comment
Share on other sites

I Changed some stuff using the links you sent me and its still not working. Any help with it now?

<HTML>
<HEAD>
<TITLE>
Find Your Lane Tech Classroom
</TITLE>
</HEAD?
<BODY>
<SCRIPT>
var Room = prompt(“Which Room Are You Looking For?”);
if (Room = [113, 111, 115, 117, 205, 211, 215, 217, 309, 313, 311, 315, 317, 321])
{
console.log(“The Staircase Closest To Your Room Is Staircase A”)
}
if (Room = [107, Main Office, 207, 213, 202, Library, 202, 307, 205, 303])
{
console.log(“The Staircase Closest To Your Room Is Staircase B”)
}
if (Room = [106, 104, 110, 206, 212, 210, 310, 308])
{
console.log(“The Staircase Closest To Your Room Is Staircase C”)
}
if (Room = [112, Weight Room, Boys Locker Room, 114A, Gym 1, PE Office, Trainer Athletic Director, 312, Gym 1 Balcony, Gym 2]0
{
console.log(“The Staircase Closest To Your Room Is Staircase D”)
}
if (Room = [114, Clinic, 118, Girls Locker Room, Swimming Pool, 120, 214, 220, 218, 214, 314, 316, 318, 320])
{
console.log(“The Staircase Closest To Your Room Is Staircase G”)
}
if (Room = [136, 134, 122, 132, 140, 222, 224, 234, 236, 238, 240, 322, 334, 324, 322A, 336, 338, 340, 342])
{
console.log(“The Staircase Closest To Your Room Is Staircase H”)
}
if (Room = [138, 144, 146, 150, 154, 148, 242, 244, 246, 248, 250, 252, 254, 258, 260, 256, 344, 346A, 346, 348, 350, 356, 360, 358, 354, 352])
{
console.log(“The Staircase Closest To Your Room Is Staircase J”)
}
if (Room = [161, 149, 147, 145, 151, 153, 157, 155, 153A, 251, 249 247, 257A, 257, 253, 255, 261, 259, 353, 351, 349 Gym 3])
{
console.log(“The Staircase Closest To Your Room Is Staircase M”)
}
if (Room = [ 143, 141, 125, 119, 123, 127, 139, 137, 243,241, 225, 221, 223, 239, 229, 345, 347, 343, 341B, 341, 339, 329, 327, 325, 323, 325])
{
console.log(“The Staircase Closest To Your Room Is Staircase O”)
}
if (Room = [129, 135, 133, 130, 128, 231, 235, 233, 230, 228, 232, 226, 331, 337, 333, 335, 330, 328, 332R, 326, 332])
{
console.log(“The Staircase Closest To Your Room Is Staircase Z”)
}
</SCRIPT>
Link to comment
Share on other sites

What is this supposed to do?

Room = [129, 135, 133, 130, 128, 231, 235, 233, 230, 228, 232, 226, 331, 337, 333, 335, 330, 328, 332R, 326, 332]

Did you read the page about operators?

Link to comment
Share on other sites

did this thread just get hijacked from the original OP?

 

@IkeWolf

Please don't post your own questions in someone else's thread.

Link to comment
Share on other sites

@stathis

My guess is this code was exploiting a bug in IE8 where name and ID attributes with the same value were interchangeable?

 

 

You are looking for an element with id newPlayerName

var nnHidden = document.getElementById('newPlayerName');

but all you have is an element with that value for the name attribute.

<INPUT type=hidden name="newPlayerName">

Try adding an id to that element with the same value

<INPUT type=hidden name="newPlayerName" id="newPlayerName">
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...