...

View Full Version : problem reloading the page



shashikala
12-06-2010, 04:35 AM
i am new to JS and need help in solving my code that's not reloading the page to download subcat list from db when you select the cat list? Any help is appreciable::(:(

Logic Ali
12-06-2010, 05:09 AM
Any help is appreciableSo is the need to show your code before anyone can help.

Your <select>'s onchange handler could look something like this:


<select onchange="sendQuery(this, 'myParameter' )">

............
<script type="text/javascript">

function sendQuery( box, param )
{
var url = location.href.split( '?' )[ 0 ]; /* Remove any existing querystring */

location.href = url + '?' + param + "=" + box.value + '&randVal=' + new Date().getTime();
}

</script>
Where 'myParameter' is the parameter you're sending in the querystring.

shashikala
12-06-2010, 04:42 PM
here is the code;
<HTML>
<HEAD>
<STYLE type="test/css"></STYLE>
<SCRIPT type="text/javascript">
function reload(form) {
var val=form.cat.options[form.cat.options.selectedIndex].value;
}
</SCRIPT>
</HEAD>
<BODY>
<TABLE style="font-family:Verdhana New;font-size:12px; font-weight:normal" width="300" border="0" align="center" cellpadding="2"% cellspacing="1">
<h3 align="center">Expense form</h3></br>
<FORM action=" " method="post"><Font face="Verdana">
<TR>
<TD align="center">Amount: <Input type="text" name="amount" size="10"/></TD>
</TR>
<TR>
<TD align="center">Month: <Input type="text" name="month" size="10"/></TD>
</TR>
<TR>
<TD align="center">
<?php
$query1=mysql_query("SELECT DISTINCT category, cat_id FROM category order by category");
//for second drop down list to check if category is selected
if(isset($cat) and strlen($cat) >'0'){
$query=mysql_query("SELECT DISTINCT subcategory FROM subcategory where cat_id=$cat order by subcategory");
}
else{
$query=mysql_query("SELECT DISTINCT subcategory, subcat_id FROM subcategory order by subcategory");
}
//end of query of subcategory dropdown list box
echo "<form method=post name=f1>";
//starting of first drop down list
echo "Category: " ."<select name='cat' onchange=\"reload (this.form)\">;
<option value=''>Select one</option>";
while($result1 = mysql_fetch_array($query1)) {
if($result1['cat_id']==@$cat){
echo "<option selected value='$result1[cat_id]'>$result1[category]</option>"."</br>";
}
else{
echo "<option value='$result1[cat_id]'>$result1[category]</option>";
}
}
echo "</select>" ."</br>";
//End of first drop down list
//Starting of second drop down list
echo "</br>" ."Subcategory: " ."<select name='subcat'><option value=''>Select one</option>";
while($result = mysql_fetch_array($query)) {
if($result['subcat_id']==@$cat){
echo "<option selected value='$result[subcat_id]'>$result[subcategory]</option>"."<BR>";
}
else{
echo "<option value='$result[subcat_id]'>$result[subcategory]</option>";
}
}
echo "</select>" ."</br>";
//End of second drop down list
?>

thanks again for looking into this....



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum