...

View Full Version : select onchange..



che_anj
01-24-2008, 04:44 PM
Hello, I have problem with regards to select onchange.. heres the link

http://etlite.com/index.php?option=com_content&task=view&id=13&Itemid=30&cur_to=2

You see the dropdown box when I choose any from that dropdown this will display

http://etlite.com/index.php?option=com_content&task=view&id=13&Itemid=30&cur_to=4

if I click any letter below it will display the list of countries that start with the letter that I click.. e.g. letter P all countries that start with letter p will display

but If i click again the dropdown to select another currency.. the list of countries will go back to the first letter which is A.

Id like to be the list remaind in P unless it click another Letter..


heres my code..


<script type="text/javascript">
function reloads(form)
{
var val=form.cur_to.options[form.cur_to.options.selectedIndex].value;
self.location='index.php?option=com_content&task=view&id=13&Itemid=30&cur_to=' + val;
}
</script> // this for the reload form when clicking the dropdown

-------------------------------------------------
<select name="cur_to" onchange="reloads(form);">
<?
while($rows=mysql_fetch_array($results))
{
if($_GET[cur_to]==$rows[id])
echo "<option value='$rows[id]' selected>$rows[countryn]</option>";
else
echo "<option value='$rows[id]'>$rows[countryn]</option>";

}
?>
</select>///this is the select box.


query code..

if(isset($_POST['cur_to']) || isset($_GET['cur_to']))
{
$curid=$_GET[cur_to];
$query="select * from currency where id='$curid'";
$result=mysql_query($query);
}
else if(!isset($_POST['cur_to']))
{
$query="select * from currency where id='1'";
$result=mysql_query($query);
}
$row=mysql_fetch_array($result);
$rates=$row[rate];


---------------array Letter----------------

<tr><td class="rc"></td>
<?
$curid=($curid!='') ? $curid : 1;
$letter=array("A","B","C","D","E","F","G","H","I","J","K","L","N","M","O","P","Q","R","S","T","U","V","W","X","Y","Z",);
$i=0;
?>
<td colspan="2" align="center"><? foreach($letter as $key)
{

echo '<button id="Edit" onClick="self.location.href=\'?option=com_content&task=view&id=13&Itemid=30&cur_to='.$curid.'&country='.$key[$i].'\';" class="alpha" id="'.$key[$i].'" >'.$key[$i].'</button>';

}?></td></tr>



anyone could help me.. thanks..

che_anj
01-24-2008, 05:17 PM
anybody could help. thanksss

Brandoe85
01-24-2008, 07:09 PM
You'll have to check if country has a value and pass that in your javascript since that's what you're doing the redirect with. You are not passing it into the query string if you look at your JS redirect.

che_anj
01-28-2008, 10:19 AM
how to pass the value of the button to the js ..



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum