-1

Before I start, let me openly declare am a ROOKIE. Am making a fantasy football site due in 2 months. Am still stuck on the backend part of it. Am having a problem making a page for editing player information where I have a drop down menu of the teams and on selection of a team, all players in that team are displayed below - preferably as links - so that when clicked one is navigated to the edit information form. I understand javascript may work a miracle as far as this is concerned. Thnx.

3
Contributors
8
Replies
9
Views
7 Years
Discussion Span
Last Post by mastia22
0

Javascript can help you upto some certain point. If you are interested in filling your select boxes dynamically, JS would be the best solution because you can do it without refreshing the web site. But if you need DB interaction, you will need more than just JS, but you will also need server side technologies in addition to javascript.

You can find helpful information about changing drop down menu content on the fly, you can refer to that page:
http://sites.google.com/site/supercodebank/home/javascript_tutorials/javascript_dynamic_option_list

If you need further help, please do not hesitate to ask. Iwill do my best to help.

Edited by fuego2008: n/a

0

I can't thank you enough 4 the help, am really gratefull. Its a step in the right direction. However, I was wondering if the names of the cities that appear on selection of a country could be displayed as link.
In my case, the cities will be players whose info I would like to edit.

0

Do you mean if all items of a drop down menu can be displayed as links (underlined and in blue color, with a "hand" shaped rollover cursor )? Or do you mean navigating to another page when an item of drop down menu is selected?

0

Ok, only thing I would like to appear as a drop down menu is the names of the clubs. The names of the players appear on the side when their respective club is selected; if possible, as links (underlined and in blue color).

0

it is really possible, you will need to search about innerHTML property of form elements such as DIV or SPAN. I will try to find a good tutorial about that topic and let you know when I find one.

0

Just use one datagrid,

If you selected a particular team in ddl,just bind the players name in one datagrid,and in datagrid_itemcreated

if(e.item.itemType=="Item" || e.Item.ItemType == "AlternateItem")
{
e.Item[0].style.add("color","blue");//Just first row(datagrid contains single row only
e.Item[0].style.add("cursor","hand");
e.Item[0].Attributes.Add("onclick","OpenEditpage()");
}

In OpenEdit page function just open yours html edit page.

0

Hey guys, am still stuck on this. My js though is still on the newbie side and thats where I need help most. Here is my code so far, it has a few comments that should help get whats happening. If it ain't clear please do ask. Thanx

<?php require_once('Connections/conntest.php'); ?>
<?php

require_once('Connections/conntest.php'); ?>
<script type="text/javascript">
window.onload = function(){
document.getElementById('lol').style.display="none"; //when page first loads it should not display this table
</script>
<?php

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_conntest, $conntest);                           //recordset for the table teams
$query_tim = "SELECT teadid, teamname FROM teams ORDER BY teamname ASC";
$tim = mysql_query($query_tim, $conntest) or die(mysql_error());
$row_tim = mysql_fetch_assoc($tim);
$totalRows_tim = mysql_num_rows($tim);

$maxRows_ply = 15;
$pageNum_ply = 0;
if (isset($_GET['pageNum_ply'])) {
  $pageNum_ply = $_GET['pageNum_ply'];
}
$startRow_ply = $pageNum_ply * $maxRows_ply;

mysql_select_db($database_conntest, $conntest);								//recordset for the table players
$query_ply = "SELECT * FROM player ORDER BY `position` ASC";
$query_limit_ply = sprintf("%s LIMIT %d, %d", $query_ply, $startRow_ply, $maxRows_ply);
$ply = mysql_query($query_limit_ply, $conntest) or die(mysql_error());
$row_ply = mysql_fetch_assoc($ply);

if (isset($_GET['totalRows_ply'])) {
  $totalRows_ply = $_GET['totalRows_ply'];
} else {
  $all_ply = mysql_query($query_ply);
  $totalRows_ply = mysql_num_rows($all_ply);
}
$totalPages_ply = ceil($totalRows_ply/$maxRows_ply)-1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form" name="form" method="post" action="">
  <label for="clubs">League</label>
  <select name="clubs" id="clubs" onchange="javascript:showplayers();"> //this function should compare the team id for the team chosen on the drop down menu to team id of the players in the database. A match should be shown in the table on this same page.
    <?php
do {  
?>
    <option value="<?php echo $row_tim['teadid']?>"><?php echo $row_tim['teamname']?></option>
    <?php
} while ($row_tim = mysql_fetch_assoc($tim));
  $rows = mysql_num_rows($tim);
  if($rows > 0) {
      mysql_data_seek($tim, 0);
	  $row_tim = mysql_fetch_assoc($tim);
  }
?>
  </select>
</form>

<p>&nbsp;</p>
<p>&nbsp;</p>
<table border="0" cellpadding="5" cellspacing="5" id="lol"> // table where match results are shown
  <tr>
    <td id="tbl">playerid</td>
    <td>plrname</td>
    <td>position</td>
    <td>teadid</td>
  </tr>
  <?php do { ?>
    <tr>
      <td><?php echo $row_ply['playerid']; ?></td>
      <td><?php echo $row_ply['plrname']; ?></td>
      <td><?php echo $row_ply['position']; ?></td>
      <td><?php echo $row_ply['teadid']; ?></td>
    </tr>
    <?php } while ($row_ply = mysql_fetch_assoc($ply)); ?>
</table>

</body>
</html>
<?php
mysql_free_result($tim);

mysql_free_result($ply);
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.