Dynamic Drop Down List Box

PeraEve
05:27:11
Help! I am trying to populate fields based on a dropdown list selection from the user. I am getting confused about how to weave javascript with PHP. This is the first time trying to do something like this. I tried to follow the example from "Dynamic population of second list box". I have provided a sample of my code. What am I doing wrong?!

function GetFieldEntry(){
<?php

echo "if (document.CMSModify.R1.value == 'Article'){";


$rsChoice = this.form.listArticles.selected;

echo "if(!empty($rsChoice)){";
include_once('../dbconnection/Connect_db2.php');
$sql = "select * from article where article_title = '$rsChoice'";
$result = mysql_query($sql);

//while ($row = mysql_fetch_array ($result))
While ($row = mysql_fetch_object($result))
{
$arttitle = $row->'article_title';
$artsubtitle = $row->'article_subtitle';
$artauthor = $row->'article_author';
$artlink = $row->'article_link';
$artimage = $row->'article_imagepath';
$artvideo = $row->'article_videopath';
$artmain = $row->'article_main';
$artcurprjt = $row->'article_currentprjt';
$arthotlink = $row->'article_hotlink';
$arttext = $row->'article_text';

echo "document.CMSModify.txtATitle.value == $arttitle;";
echo "document.CMSModify.txtASubtitle.value == $artsubtitle;";
echo "document.CMSModify.txtAAuthor.value == $artauthor;";
echo "document.CMSModify.txtALink.value == $artlink;";
echo "document.CMSModify.txtAImage.value == $artimage;";
echo "document.CMSModify.txtAVideo.value == $artvideo;";
echo "document.CMSModify.optAMTopic.value == $artmain;";
echo "document.CMSModify.optAHotLink.value == $arthotlink;";
echo "document.CMSModify.optACurPrjt.value == $artcurprjt;";
echo "document.CMSModify.tabAText.value == $arttext;";

}
mysql_close("test");
//print"<script language='JavaScript' type='text/javascript'>set_data('$state', '$city')</script>";
echo "}";
echo "}";
?>
jaimin
06-24-2011
Dynamic populating the drop down list based on the selected value of first list
here i put my code n when i put this code i got value of first ddl in query string but after refresh the page the valu which i bound with first ddl is gone because of refresh.

<?php
@$manual_id=$_GET['manual_id'];
if(isset($_POST['submit']))
{

$cdate = date('Y-m-d');
mysql_query("insert into tbl_phone(manual_id, member_ship, phone, total_min, cdate, country) values('".$_POST['manual_id']."', '".$_POST['member_ship']."' ,'".$_POST['phone']."', ".$_POST['total_min'].", '".$_POST['cdate']."', '".$_POST['country']."')");
}

?>
<link type="text/css" href="style/jquery.ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
<script type="text/javascript" src="js/jquery.ui.core.js"></script>
<script type="text/javascript" src="js/jquery.ui.datepicker.js"></script>
<script type="text/javascript">

$(function() {
$("#datepicker").datepicker();
});

</script>

<SCRIPT language=JavaScript>
function reload(form)
{
var val=form.manual_id.options[form.manual_id.options.selectedIndex].value;
self.location='add_phone.php?manual_id=' + val ;
}

</script>

<h2>Add Phone</h2>
<p><a href="add_phone.php">Add Phone</a>| <a href="list_phone.php" >List Phone</a></p>
<form action="add_phone.php" name="" method="post" >
<table width="100%" align="center" border="1" cellpadding="5" cellspacing="0">
<tr>
<td width="30%"><b>Member Id </b></td>

<td>: <select name="manual_id" onchange="reload(this.form);">
<option value="">Select Manual Id</option>
<?php $select_id = mysql_query("select * from tbl_register ");
while($row = mysql_fetch_array($select_id))
{
if($row['manual_id']==@$manual_id)
{
?>
<option value="<?php echo $row['manual_id']; ?>"><?php echo $row['manual_id']; ?></option>
<?php

}
else
{?>
<option value="<?php echo $row['manual_id']; ?>"><?php echo $row['manual_id']; ?></option>
<?php }
}

?>

</select>

</td>
</tr>
<tr>
<td width="30%"><b>Membership </b></td>

<td>: <select name="member_ship">
<option value="">Select Membership</option>
<?php $select_atype = mysql_query("select * from tbl_register where manual_id='".$manual_id."' ");
while($row = mysql_fetch_array($select_atype))
{
?>
<option value="<?php echo $row['atype']; ?>"><?php echo $row['atype']; ?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td width="30%"><b>Country</b></td>
<td>: <select name="country">
<option value="" selected="selected">Select Country</option>
<?php
$select_country = mysql_query("select * from tbl_rate");
while($row = mysql_fetch_array($select_country))
{
?>
<option value="<?php echo $row['country']; ?>"><?php echo $row['country']; ?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td width="30%"><b>Phone</b></td>
<td>: <input type="text" name="phone" value="" size="30" /></td>
</tr>
<tr>
<td width="30%"><b>Minute</b></td>
<td>: <input type="text" name="total_min" value="" size="30" /></td>
</tr>
<tr>
<td width="30%"><b>Date</b></td>
<td>: <input type="text" id="datepicker" name="cdate" value="" /> </td>
</tr>

<tr>
<td width="30%">&nbsp;</td>
<td><input type="submit" name="submit" value="Submit" onClick="valid()" /></td>
</tr>
</table>
</form>
pls help me to short out this problem.
kannanbtech303
07-09-2011
how to retrive the database value ?(you select any one menu_name and display description of the menu) please help me...............
<table>
<tr>
<td width="173" height="33" align="right" class="content">Menu Name</td>
<td width="208" align="left"><select name="status" onChange="valuesubmit(this)" >
<option value="">---Select Menu---</option>
<?php require 'databasecon.php';
$sql=mysql_query("select * from managing_menu");
while($row=mysql_fetch_array($sql))
{
?>
<option value="" ><?php echo $row['menu_name'];?></option>
<?php } ?>
</select>
</tr>
<tr>
<td colspan="2" align="center">
<textarea id="elm1" rows="15" cols="80" style="width: 100%; height:100%" name="description">
<?php
echo $row['description'];
?>
</textarea>
</td>
</tr>
</table
Please Login to post your reply or start a new topic