javascript

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

 



I have a form that resides within a php function().  And, I would like to call 
a javascript function from an "onChange" event of a <selection> tag (a drop 
down list box).

Is there any problem with trying to call a javascript function from within a 
php function?  I tried putting the javascript function in the <head>.  But, 
that didn't work.

The form can be seen at:  http://www.crotchett.com/mcachess/register.php

The code in question is below.  I removed the redundant and irrelevant parts 
and noted where that was done:

Thanks,
backdoc

<?php
        . . . . snip snip . . . .   
<form method="post" action="./register.php">
        <div id="col1">
        <h3>Student Information</h3>
        <table>
        <tr><td align="right">Event Name:</td>
        <td>
                <select name="event">
                        <option <?php if($_POST["event"] == "0") echo 
"selected"; ?> value="0">Select an event . . .</option>
                        <?php
                        while($row = mysql_fetch_row($events))
                        {
                                echo "<option ";
                                if($_POST["event"] == $row[0])
                                        echo "selected ";
                                echo "value=\"", $row[0], "\">", $row[1], 
"</option>";
                        }?>
                </select>
        </td><td id="red"><?php echo $errors["events"]; ?></td></tr>
        . . . . snip snip . . . .   
        </div><!-- ends col1 -->
        <div id="col2">
        <h3>Coach or Teacher Information</h3>
        <table>
        . . . . snip snip . . . .
<script language="javascript">
function fillCoach(text)
{
alert(text);
}
fillCoach("this works!!!");
</script>
                <select name="coachPicker">
                        <option selected value="0" onChange="fillCoach('But, 
this doesnt!!')">Find a coach/teacher . . .</option>
                        <?php
                        while($row = mysql_fetch_row($coaches))
                        {
                                echo "<option ";
                                if($_POST["coachPicker"] == $row[0])
                                        echo "selected ";
                                echo "value=\"", $row[0], "\">", $row[2], ", 
", $row[1], "</option>";
                        }?>
                </select>
        </td>
        . . . . . snip snip . . . .
        </div><!-- ends col2 -->
        <input type="hidden" value="1" name="_submitted" />
</form>
<?php } ?>

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux