p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: Any function like OnCellChange()


Message #1 by "Gagneet Singh" <gagneet@a...> on Sat, 5 Oct 2002 13:08:32 +0530
Hi!
    I am working on a site which contains a combo box. Now depending on this
combobox contents, I would like to change the contents of another. The code
for displaying the first combo box i have given below.

    Is the above possible? There is a function OnCellChange() in VC++, can
the same be implemented in PHP.

Thanx for the help

Gagneet


CODE:

<tr>
 <td width="15%"><p align="center">
  <select size="1" name="ver_no">

 <?
  /* Select the database.
  */

  $db_name = "project_db";
  $ver_tbl = "versions_tbl";

  $db_access = @mysql_select_db($db_name, $connection) or die("Access Log
database not found!!");

  /* Extract the versions available in the 'versions_tbl' and iterate
  through them, displaying each so that they can be displayed to the
  user in the combo box described below.
  */
  $query = "select version_no from $ver_tbl order by version_id";
  $result = @mysql_query($query) or die("Error in the Query: $query".
mysql_error());

  /* Once the resultset has been returned, use the mysql_fetch_object()
function in
  combination with a while loop, to iterate through it and format the fields
in each
  row for display.
  Check if the record is present.
  */
  if(mysql_num_rows($result) > 0)
  {
   /* Iterate through the resultset and print the project names
   in the combo box described below in the main HTML page.
   */
   while($row = mysql_fetch_object($result))
   {
    /* Create the OPTION element statement which will hold the individual
    version numbers.
    */
 ?>
   <option><? echo $row->version_no; ?></option>";
 <?
   }
  }

  /* Now continue with the SELECT element which dispalys the combo box.
  */
 ?>

  </select></p>
 </td>
   <tr>

Message #2 by "jorge" <jorge@d...> on Sat, 5 Oct 2002 08:44:48 -0500
Hi Gagneet:
you use Java Script onBlur="do_something();" or onChange="do_this();"
here is a function that has the second select box visibility hidden when the
functio is called the second box appears
with the values specified in it

function adultos3()

 {

  var xxx = eval(document.myForm.selectBox1.value);

   var men3 = document.myForm.selectBox2;

   men3.style.visibility = "visible";

   //alert(xxx);

   var junt = xxx/3;

   men3.length = junt + 1;

   for(var i = 1; i < junt + 1; i++)

    {

    men3.options[i].text= i;

    men3.options[i].value= i;

    }

    men3.focus();

 }//FIN FUNCION ADULTOS3
if you want to use PHP the page need to be refreshed

Saludos

Jorge Cordero



----- Original Message -----
From: "Gagneet Singh" <gagneet@a...>
To: "beginning php" <beginning_php@p...>
Sent: Saturday, October 05, 2002 2:38 AM
Subject: [beginning_php] Any function like OnCellChange()


> Hi!
>     I am working on a site which contains a combo box. Now depending on
this
> combobox contents, I would like to change the contents of another. The
code
> for displaying the first combo box i have given below.
>
>     Is the above possible? There is a function OnCellChange() in VC++, can
> the same be implemented in PHP.
>
> Thanx for the help
>
> Gagneet
>
>
> CODE:
>
> <tr>
>  <td width="15%"><p align="center">
>   <select size="1" name="ver_no">
>
>  <?
>   /* Select the database.
>   */
>
>   $db_name = "project_db";
>   $ver_tbl = "versions_tbl";
>
>   $db_access = @mysql_select_db($db_name, $connection) or die("Access Log
> database not found!!");
>
>   /* Extract the versions available in the 'versions_tbl' and iterate
>   through them, displaying each so that they can be displayed to the
>   user in the combo box described below.
>   */
>   $query = "select version_no from $ver_tbl order by version_id";
>   $result = @mysql_query($query) or die("Error in the Query: $query".
> mysql_error());
>
>   /* Once the resultset has been returned, use the mysql_fetch_object()
> function in
>   combination with a while loop, to iterate through it and format the
fields
> in each
>   row for display.
>   Check if the record is present.
>   */
>   if(mysql_num_rows($result) > 0)
>   {
>    /* Iterate through the resultset and print the project names
>    in the combo box described below in the main HTML page.
>    */
>    while($row = mysql_fetch_object($result))
>    {
>     /* Create the OPTION element statement which will hold the individual
>     version numbers.
>     */
>  ?>
>    <option><? echo $row->version_no; ?></option>";
>  <?
>    }
>   }
>
>   /* Now continue with the SELECT element which dispalys the combo box.
>   */
>  ?>
>
>   </select></p>
>  </td>
>    <tr>
>
>


Message #3 by "Gellings, C.O." <gellingsco@p...> on Sat, 5 Oct 2002 17:26:45 +0200
A lot is possible you can set the select tag's
onChange="javascript: document.forms[.. enter form index nr..].submit()"
and have php set the select's value after submission to the HTTP_POST_ or
HTTP_GET_VARS['selectname'] 's value

mth

Carl

-----Original Message-----
From: Gagneet Singh [mailto:gagneet@a...]
Sent: 05 October 2002 09:39
To: beginning php
Subject: [beginning_php] Any function like OnCellChange()


Hi!
    I am working on a site which contains a combo box. Now depending on this
combobox contents, I would like to change the contents of another. The code
for displaying the first combo box i have given below.

    Is the above possible? There is a function OnCellChange() in VC++, can
the same be implemented in PHP.

Thanx for the help

Gagneet


CODE:

<tr>
 <td width="15%"><p align="center">
  <select size="1" name="ver_no">

 <?
  /* Select the database.
  */

  $db_name = "project_db";
  $ver_tbl = "versions_tbl";

  $db_access = @mysql_select_db($db_name, $connection) or die("Access Log
database not found!!");

  /* Extract the versions available in the 'versions_tbl' and iterate
  through them, displaying each so that they can be displayed to the
  user in the combo box described below.
  */
  $query = "select version_no from $ver_tbl order by version_id";
  $result = @mysql_query($query) or die("Error in the Query: $query".
mysql_error());

  /* Once the resultset has been returned, use the mysql_fetch_object()
function in
  combination with a while loop, to iterate through it and format the fields
in each
  row for display.
  Check if the record is present.
  */
  if(mysql_num_rows($result) > 0)
  {
   /* Iterate through the resultset and print the project names
   in the combo box described below in the main HTML page.
   */
   while($row = mysql_fetch_object($result))
   {
    /* Create the OPTION element statement which will hold the individual
    version numbers.
    */
 ?>
   <option><? echo $row->version_no; ?></option>";
 <?
   }
  }

  /* Now continue with the SELECT element which dispalys the combo box.
  */
 ?>

  </select></p>
 </td>
   <tr>




  Return to Index