Forum Moderators: coopster
<p><select class=select size="120" name="VwRc" style="width: 780; height: 250; FONT-FAMILY: Lucida Console, Courier New; FONT-SIZE: x-small;" LANGUAGE="javascript" onchange="return VwRc_onchange()">
<? while ($rsTable=mysql_fetch_array($rs))echo "<option>".AppendSpace($rsTable["ActId"],8), AppendSpace($rsTable["ActDate"],12)?>
</option>
</select>
this is my code. the data displays on my select box properly. as you will notice i am putting the data from 2 fields in my table in a row of my select box. i have in my form 2 textbox (ID, Date) to check if the data selected from the select box is being displayed. however, if I select something there is no data being displayed in my 2 textbox. I think the option should have a value such as echo "<option value=(this is where my problem starts)>".AppendSpace...
i really don't know what to do anymore. pls help me.
I also tried but nothing is displayed in my selectbox:
<option value="<? echo $rsTable['ActId'];?>,<? echo $rsTable['ActDate'];?>"> <?echo AppendSpace($rsTable["ActId"],8)?> <? echo AppendSpace($rsTable["ActDate"],12)?>
what should be my code then?
hope someone here could help me.
One error i noted was with your while loop, it should be something like the code below.
<?
while ($rsTable=mysql_fetch_array($rs))
{
echo "<option>".AppendSpace($rsTable["ActId"],8),AppendSpace($rsTable["ActDate"],12)."</option>";
}
?>
I am not sure about whether a value is needed when using Javascript, maybe someone else can help with that.
Hope this helps
Cheers
Richard
<script ID="clientEventHandlersJS" LANGUAGE="javascript">
<!--
var sel_array = new Array();
var totalot = totalreg = 0;function subpopUpdate(s) {
// alert (document.ViewForm.passActDate.value);
if (document.ViewForm.passActDate.value == "0000-00-00")
{
window.alert("Click on one selection at the above to be updated");
}
else
if (document.ViewForm.VwRc.value == "No Record")
{
window.alert("No Record to pick!");
}
else
{
addWindow = window.open(s,"dataview");
addWindow.focus();
}
function VwRc_onchange() {var tempVwRcValue = document.ViewForm.VwRc.value;
document.ViewForm.passActId.value = extract_val(tempVwRcValue,1);
document.ViewForm.passActDate.value = extract_val(tempVwRcValue,2);
document.ViewForm.passPrjCode.value = extract_val(tempVwRcValue,3);}
//-->
</script><body>
<form method="POST" id="ViewForm" name="ViewForm" action="FilterView.php" LANGUAGE="javascript">
<input name=passActId value="">
<input name=passActDate value="0000-00-00">
<?
if ($_POST['submit']=="")
{
include "FilterOnLoad2.php";
}
if ($_POST['submit']=="FILTER")
{
include "Filter.php";
}
?>
<script LANGUAGE="javascript">
<!--
function extract_val(str,item)
{
var src,strval,xstr;
xstr = str+",#*$!,";
for(a=1;a<=item;a++)
{
iPos = xstr.search(",");
strval = xstr.substr(0,iPos);
xstr = xstr.substr(iPos+1);
}
return strval;
}
function extract_date(str,item)
{
var src,strval,xstr;
xstr = str+",#*$!,";
for(a=1;a<=item;a++)
{
iPos = xstr.search("-");
strval = xstr.substr(0,iPos);
xstr = xstr.substr(iPos+1);
}
return strval;
}
//-->
</script>
</body>
here is the code for filteronload2.php
<? // connection to database here.if (($rsTable>0))
{
function AppendSpace($sString,$iMaxChar)
{
extract($GLOBALS);$sSpace="";
for ($i=1; $i<=($iMaxChar-strlen($sString)); $i=$i+1)
{
$sSpace=$sSpace." ";
}
$AppendSpace=$sString.$sSpace;
return $AppendSpace;
}?><p><select class=select name="VwRc" LANGUAGE="javascript" onchange="return VwRc_onchange()">
<?
while ($rsTable=mysql_fetch_array($rs))
$val = AppendSpace($rsTable['ActId'],8) . ' '. AppendSpace($rsTable['ActDate'],12);echo '<option value="'. $val .'">'. $val . '</option>';
?>
</select><p><font size=4 color=navy><? print "Filtered Records from: ";?><? print $DateFirst;?><? print " to ";?><? print $DateEnd;?></font></p>
<?}
else {
?>
<p><select name="VwRc" LANGUAGE=javascript onchange="return VwRc_onchange()" ><option value = "No Record">No Record(s) Found</option>
</select><p><font size=4 color=navy><? print "Filtered Records from: ";?><? print $DateFirst;?><? print " to ";?><? print $DateEnd;?></font></p>
<? }?>
my problem is now that the data displayed on my select box is only the 1st data in my database in a month. second is when i select the data, the data displayed in my pass.ActId is all the data in my select box and in my pass.ActDate is 11. For example the data in my select box has 2 for ActId and 2004-11-02 for ActDate.
pass.ActId box displays 2 2004-11-04 and pass.ActDate displays only 11.
hope you could help me with this. i really don't know what to do anymore.