Jump to content

how to dynamically populate a dropdown using 1 drop down and 1 textbox value?


Recommended Posts

Hi

i have a table1 with fields clientid, date and filename along with other fields.

 

i have to fill another table2 and i am using html form for that. in this form the user gets the client ids populated in a dropdown from the table1. the user selects a date which is taken in a text box using a simple javascript calendar. now the filename matching to the corresponding clientid and date has to be dynamically populated in a drop down.

 

i am able to populate the filename drop down corresponding to a client id. i am making a mysql query for that. and then make the page reload. But i am unable to get the list populated using the combination of both the fields(clientid and date)...how do i do it?

 

i think i am passing the value of the textbox in a wrong way. here is my code n relevant parts:

____________________________________________________________________

 

<script type="text/javascript">

function reload(form){

var val=form.clientid.options[form.clientid.options.selectedIndex].value;

 

var val1=form.receivedon.value;

//Thie line below doesnt work

//self.location='dbinven_entry.php?clientid=' + val '&receivedon=' + val1

 

self.location='dbinven_entry.php?clientid=' +val;

}

 

 

</script>

 

</head>

 

<body>

<?php

echo"<h1><center>Database Inventory</h1></center>";

$quer2=mysql_query("SELECT DISTINCT clientid FROM ClientInfo");

 

$clientid=$_GET['clientid'];

$receivedon=$_GET['receivedon'];

if(isset($clientid) and strlen($clientid) > 0){

$quer=mysql_query("SELECT DISTINCT filename FROM ddi where clientid='$clientid'");

}else{$quer=mysql_query("SELECT DISTINCT filename FROM ddi"); }

 

 

echo "<form action=inserttodbinven.php method=post name=dbinven >";

 

//Starting of clientID drop downlist autofed from ClientInfo //

echo "<table> <tbody>";

echo "<tr>";

echo "<td>";

echo "<label for ='clientid'>Client ID:</label></td>";

echo "<td><select name='clientid' onchange=\"reload(this.form)\"><option value=''>Select one</option>";

while($noticia2 = mysql_fetch_array($quer2)) {

if($noticia2['clientid']==@$clientid){echo "<option selected value='$noticia2[clientid]'>$noticia2[clientid]</option>"."<BR>";}

else{echo "<option value='$noticia2[clientid]'>$noticia2[clientid]</option>";}

}

echo "</select></td></tr>";

 

//end of the drop down list //

?>

<tr><td><label for="receivedon">Received on:</label></td>

<td><input type="text" name="receivedon" id="receivedon" value= "<?php $receivedon ?>" readonly onclick="fPopCalendar('receivedon')" /></td></tr>

<?php

 

echo "<tr><td><label for ='filename'>Parent File Name:</label></td>";

echo "<td><select name='filename'><option value=''>Select one</option>";

while($noticia = mysql_fetch_array($quer)) {

echo "<option value='$noticia[filename]'>$noticia[filename]</option>";

}

?>

______________________________________________________________________

 

thanks in advance for your help!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.