I am having trouble mixing php and javascript together. What I want to happpen is when a user selects from the drop down the javascript function is run, to grab the new email id. Thanks in advance for the assistance
PHP Code:<?php
$selected = "";
echo '<select name="email_type" size="1" onchange="emailType(this.value)">';
echo '<option value="0"> Select...</option>';
$query = "SELECT id, subject FROM table WHERE category = 'Templated Email' ORDER BY `category` ASC";
$result = mysql_db_query($dbase,$query,$id);
$number = mysql_num_rows($result);
$i = 0;
while($i<$number):
$email_id = mysql_result($result,$i,0);
$subject = mysql_result($result,$i,1);
echo '<option $selected value='.$email_id.'>'.$subject.'</option>';
$i++;
endwhile;
?>
<script type="text/javascript">
function emailType(){
if (document.form1.email_type.value == 1)
{
<? $email_id = 1; ?>
}else{
<? $email_id ?> == document.form1.email_type.value;
}
}
</script>



Reply With Quote


Bookmarks