[eluser]rajyakshmik[/eluser]
//view code
function dealsearch()
{
if(document.form1.zip.value=='' && document.form1.keywords.value=='')
{
document.form1.zip.value=0;
document.form1.keywords.value=0;
document.form1.action="main/search/N";
}
if(document.form1.zip.value!='' && document.form1.keywords.value=='')
{
document.form1.keywords.value=0;
document.form1.action="main/search/S1";
}
if(document.form1.zip.value=='' && document.form1.keywords.value!='')
{
document.form1.zip.value=0;
document.form1.action="main/search/S2";
}
else
{
document.forms[0].action="main/search/S";
}
//document.form1.action="main/search/S";
}
<form method="post" name="form1">
<div id="Layer4">
</div>
<div id="Layer5">
<div id="Layer6">
<table width="98%" height="69" border="0" align="center" cellspacing="0">
<tr>
<td colspan="7"> <img src="images/searchdeal.jpg" /></td>
</tr>
<tr>
<td width="12%" align="right" class="dealsearch" >ZipCode</td>
<td width="14%">
<input type="text" name="zip" width="20" tabindex="7" size="5" maxlength="5" value="<?php if($_SESSION['zip']!='') echo $_SESSION['zip'];?>"/> </td>
<!--<<td width="12%" align="right" class="dealsearch">Business Type </td>
<td width="22%">select name="businesstype" tabindex="8"><option value="0">--Select Business Type--</option>
<?php
//foreach ($query2->result() as $row)
// {
?>
<option value='<?php //echo $row->MerchantType;?>' <?php //if($_SESSION['businesstype']!='') { if($row->MerchantType == $_SESSION['businesstype']) //echo "selected"; }?> ><?php //echo $row->MerchantType;?></option>";
<?php // }
?>
</select></td>-->
<td width="9%" align="right" class="dealsearch">Keywords</td>
<td width="26%">
<input type="text" name="keywords" width="20" size="30" tabindex="9" value="<?php if($_SESSION['keywords']!='') echo $_SESSION['keywords'];?>"/></td>
<td width="12%"><input type="image" src="images/searchbtn.jpg" border="0" tabindex="10" > </td>
</tr>
</table>
</div>
</div>
</form>
//Controller code
function search($key)
{
$condi ='';
$codetype='';
$data['msg'] ='';
if($key == 'S')
{
if($_POST['zip']!='0')
$_SESSION['zip'] = $_POST['zip'];
if($_POST['keywords']!='0')
$_SESSION['keywords'] = $_POST['keywords'];
}
else if($key == 'S1')
{
if($_POST['zip']!='0')
$_SESSION['zip'] = $_POST['zip'];
}
else if($key == 'S2')
{
// echo '===>'.$_POST['keywords'];
if($_POST['keywords']!='0')
$_SESSION['keywords'] = $_POST['keywords'];
}
else if($key == 'N')
{
$_POST['zip']='';
//$_POST['businesstype']='';
$_POST['keywords']='';
$_SESSION['keywords']='';
//$_SESSION['businesstype']='';
$_SESSION['zip']='';
}
else
{
//echo 'sfsdf';
$_POST['zip']='';
//$_POST['businesstype']='';
$_POST['keywords']='';
$_SESSION['keywords']='';
//$_SESSION['businesstype']='';
$_SESSION['zip']='';
}
//echo '===>'.$_SESSION['keywords'];
if($_SESSION['zip']!='')
{
$condi.= " and merchants.zip ='$_SESSION[zip]'";
}
/* if($_SESSION['businesstype']!=0)
{
$condi.= " and merchants.MerchantType ='$_SESSION[businesstype]'";
}*/