RE: question on <select>

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here is the complete code. In the one line Java script that I have I am
setting the value. So what am I missing?

Quicksearch.php file has the following code

<br>

<table class='form'>

      <tr>

            <th>Steps 1-4</th>

      </tr>

 

      <tr><td>

            <form name="fcountry" method="post">

                  <?php  require("country_build.php");?>

                  <input type="text" name="newcountry" value="">

                  

      </form>

 

</td></tr>

</table>

<!-- quicksearch.php   end -->

 

<script language="JavaScript">

<!--

function changeMenu()

  {

      document.fcountry.newcountry.value =
document.fcountry.country.options[document.fcountry.country.selectedIndex].v
alue;

 } 

--> 

</script>

 

Countrty_buil.php has the following

 

<?php

require_once("util.php");

 

echo "<SELECT name=\"country\" class=\"input\"  onchange=\"changeMenu()\">";

//

// initialize or capture the country variable

$country = !isset($_REQUEST['country'])? "Select a country":
$_REQUEST['country'];

$countrySQL = !isset($_REQUEST['country'])? "*": $_REQUEST['country'];

echo "<option value='$countrySQL' SELECTED>$country</option>";

$query = "SELECT country FROM ". TABLECOUNTRY . " ORDER BY country ASC";

// pconnect, select and query

if ($link_identifier = mysql_pconnect(DBSERVERHOST, DBUSERNAME, DBPASSWORD))
{

      if ( mysql_select_db(DBNAME, $link_identifier)) {

            // run the query

         $queryResultHandle = mysql_query($query, $link_identifier) or die(
mysql_error() );

         $ctrRows = mysql_num_rows($queryResultHandle); // row counter

            // if data exists then $rows will be 1 or greater

            if( $ctrRows == 0 ) {

                  echo"<option value='*'>No data found</option></select>";

            }else{

                  // build the select list

                  while($row = mysql_fetch_object($queryResultHandle)) { //
grab a row

                        echo "<option
value=\"$row->country\">$row->country</option>";

                  }

                  echo "</SELECT><br><br>";

                                    

            }

      }else{ // select

            echo mysql_error();

      }

}else{ //pconnect

      echo mysql_error();

}

?>

 


-----Original Message-----
From: dpgirago@xxxxxxxxxxxxxx [mailto:dpgirago@xxxxxxxxxxxxxx] 
Sent: Wednesday, May 12, 2004 12:14 PM
To: php-db@xxxxxxxxxxxxx
Subject: RE:  question on <select>

> Thanks so much but I am so new to all this so need more explanation 
please.
> I think at this point I don't mind the round trip to the server side 
till I
> find a better way. But for now I think I have what you are suggesting 
but
> then why my "echo" is not retuning anything :
> <form name="fcountry" method="post" action="$PHP_SELF">
>                                                <?php 
require("country_build.php");?>
>                                                <input type="text" 
name="newcountry" value="">
>                                                <?php echo 
$_POST['newcountry'];?>
>                </form>


Well, there is no value assgined to $_POST['newcountry'] in your example. 
How are you getting a value to that form field?

dave

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux