Re: [PHP3] Dynamic Pull downs with PHP/Javascript..
| From: | Frewuill Rodriguez | Date: | Wed, 24 May 2000 21:34:16 +0000 |
| Subject: | Re: [PHP3] Dynamic Pull downs with PHP/Javascript.. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-483@lists.php.net to get a copy of this message | ||
try to check yours " be sure they are in corrects pairs.. anyway i would
suggest you to change them by '.
i.e. i would change echo "<script language=\"JAVASCRIPT\">\n"; by echo
"<script language='JAVASCRIPT'>\n";
it's a better way to avoid errors.. at least i think so.
Chad Day <cday@beachassociates.com> wrote in message
news:A8D9B16D2196D2118B6E00A0C9E307F4238533@beachpdc1.beachassociates.com...
>
>
> After reading the archive and finding this helpful
> link:
>
>
> http://www.weberdev.com/get_example.php3?count=405
>
> I went off to try to do this myself, but ran into
> some problems..
>
> echo "<script language=\"JAVASCRIPT\">\n";
> echo "function UpdateTeam()\n";
> echo "{\n";
> echo "\tvar Team =
> document.choose_lt.team.options.length;\n";
> echo "\twhile (Team > 0)\n";
> echo "\t{\n";
> echo "\t\tTeam--;\n";
> echo
"\t\tdocument.choose_lt.team.options[Team].text
> = \";\n";
> echo
"\t\tdocument.choose_lt.team.options[Team].value
> = \";\n";
> echo "\t}\n\n";
> echo "\tdocument.choose_lt.team.options[0].selected
=
> true;\n\n";
>
> echo "\tvar LeagueSelected = 0;\n";
> echo
>
"\twhile(document.choose_lt.league.options[LeagueSelected].selected==false)
> LeagueSelected++;\n\n";
>
> $LTLeague = "";
> $TeamCount = 0;
> $RowCount = 0;
>
> $leaguequery = mysql_query("select LEAGUENAME,
> LEAGUEID from leagues order by LEAGUENAME");
>
> $numlq = mysql_num_rows($leaguequery);
>
> while($RowCount < $numlq)
>
>
> $LT_ID = $LT_id[$RowCount];
> $LT_League = $LT_league[$RowCount];
> $LT_Team = $LT_team[$RowCount];
>
> if($LTLeague != $LT_League)
>
> if($LTLeague != "")
>
> echo"\t}\n";
> }
>
> echo
> "\tif(document.choose_lt.league.options[LeagueSelected].value ==
> '$LT_League')\n";
> echo "\t{\n";
>
> echo
> "\t\tdocument.choose_lt.team.options[$TeamCount].value = '$LT_ID';\n";
> echo
> "\t\tdocument.choose_lt.team.options[$TeamCount].text = '$LT_Team';\n";
> $TeamCount++;
> $RowCount++;
> }
>
> echo "\t}\n";
>
> echo "}\n";
>
> echo "</SCRIPT>\n\n";
>
>
> ?>
>
> <body>
>
> <form name=choose_lt action=addplayer.php
method=GET>
>
>
> Name: <input type=text name=FIRSTNAME size=25
> maxlength=40>
> Last Name: <input type=text name=LASTNAME size=25
> maxlength=40>
> Jersey #: <input type=text name=JERSEYNUM size=3
> maxlength=3>
> <?
> echo "<select name=LEAGUENAME
> onChange=\"UpdateTeam();\">\n";
>
> $cquery = mysql_query("select distinct LEAGUENAME
> from leagues order by LEAGUENAME");
>
> $numcq = mysql_num_rows($cquery);
>
>
> $RowCount = 0;
>
> while ($RowCount < $numcq)
>
>
> echo "<OPTION>";
> print $row["LEAGUENAME"];
> echo "</OPTION>";
> $RowCount++;
>
> }
>
> echo "</select>";
>
> print("Team: <select name=TEAMNAME>");
>
> $RowCount = 0;
>
> $tquery = mysql_query("select TEAMNAME from teams
> order by TEAMNAME");
> $numte = mysql_num_rows($tquery);
>
> while ($RowCount < $numte)
>
>
> echo "<OPTION>";
> print $row["TEAMNAME"];
> echo "</OPTION>";
> }
>
> echo "</select>\n";
> echo "<input type=\"submit\">";
> echo "</form>";
>
> echo "<script
> language=\"Javascript\">UpdateTeam();</SCRIPT>\n";
>
>
> It keeps giving me a parse error on the last line
of
> the script.. I'm fairly sure I missed a }
> somewhere, but I'm not sure where, and if this code
> is even going to work.. My goal is that a user
> chooses a league, he gets the corresponding teams
in
> the second select box. Does anyone have any
> example code for this? I've been unable to find any
> except for that link..
>
>
> Chad Day
> Beach Associates
>
> When I speak german... I think german in my head... but like...Do skript
> kiddies see a w40l3 8uncha 1's and 0's and 3's and 4's and 7's in
> their
> h34d'5 w43n t43y R +a1k1n6 ? -- SirStanley
>
>
> --
> PHP 3 Mailing List <http://www.php.net/>
> To unsubscribe, send an empty message to php3-unsubscribe@lists.php.net
> To subscribe to the digest, e-mail: php3-digest-subscribe@lists.php.net
> To search the mailing list archive, go to:
http://www.php.net/mailsearch.php3
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>