Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Multi Fields Search Form
Old 05-19-2010, 07:53 AM Multi Fields Search Form
Super Talker

Posts: 128
Name: Jose daSilva
Trades: 0
Hi there!!!

I manage to do the following search while ago:


Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>

<style type="text/css">
form {
        height: -2px;
        margin: 0px;
        padding: 0px;
        left: 0px;
        top: 0px;
        right: 0px;
        bottom: 0px;
        visibility: inherit;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script>
function activate(form){
        if(form.tipo.value != '0'){
                document.getElementById('idsubcat').disabled = false;
                document.getElementById('cbviews').style.display = 'none';
                        document.getElementById('text').style.display = 'block';
                document.getElementById('prices').style.display = 'none';
        } else {
                document.getElementById('idsubcat').disabled = true;
                document.getElementById('txtview').disabled = true;
                          document.getElementById('txtview').style.display = 'block';
                document.getElementById('cbviews').style.display = 'none';
                document.getElementById('text').style.display = 'block';
                document.getElementById('prices').style.display = 'none';
          }
}
function activate2(form){
        if(form.subcat.value !='0') {
                document.getElementById('idbt1').disabled = false;
                document.getElementById('txtview').disabled = false;
                                     document.getElementById('text').style.display = 'block';
                                document.getElementById('prices').style.display = 'none';
                                document.getElementById('cbviews').style.display = 'none';
                                if(form.subcat.value == 'view') {
                                        document.getElementById('cbviews').style.display = 'block';
                                document.getElementById('text').style.display = 'none';
                                document.getElementById('txtview').style.display = 'none';
                                document.getElementById('prices').style.display = 'none';
                                } else if(form.subcat.value == 'price') {
                                        document.getElementById('prices').style.display = 'block';
                                document.getElementById('text').style.display = 'none';
                                document.getElementById('txtview').style.display = 'none';
                                document.getElementById('cbviews').style.display = 'none';
                                }  else if(form.subcat.value !='price' && form.subcat.value !='view' && form.subcat.value=='rooms'){
                                document.getElementById('prices').style.display = 'none';
                                document.getElementById('text').style.display = 'block';
                                document.getElementById('txtview').style.display = 'block';
                                document.getElementById('cbviews').style.display = 'none';
                                form.search.value = '----- 0 -> 10 -----';
                                } else if(form.subcat.value !='price' && form.subcat.value !='view' && form.subcat.value!='rooms'){
                                document.getElementById('prices').style.display = 'none';
                                document.getElementById('text').style.display = 'block';
                                document.getElementById('txtview').style.display = 'block';
                                document.getElementById('cbviews').style.display = 'none';
                                form.search.value = '';
                                }
               } else {
                document.getElementById('txtview').disabled = true;
                document.getElementById('idbt1').disabled = true;
                                document.getElementById('text').style.display = 'block';
                                document.getElementById('txtview').style.display = 'block';
                document.getElementById('cbviews').style.display = 'none';
                document.getElementById('prices').style.display = 'none';
        }
}
function delete(form){
        form.search.value = '';
}
function send(form)
{
 form.action="newsearch.php?idioma=<? echo"$idioma"; ?>&tipo=<? echo"$tipo"; ?>&subcat=<? echo"$subcat"; ?>&views=<? echo"$views"; ?>&search=<? echo"$search"; ?>&min=<? echo"$min"; ?>&max=<? echo"$max"; ?>&ord=id&ord2=desc";
 form.submit();
}
</script>
<form name='search' method='POST' action="newsearch.php?idiom=<? echo"$idiom"; ?>&ord=id&ord2=desc&typo=<? echo"$tipo"; ?>&subcat=<? echo"$subcat"; ?>&views=<? echo"$views"; ?>&search=<? echo"$search"; ?>&min=<? echo"$min"; ?>&max=<? echo"$max"; ?>&ord=id&ord2=desc">
      <table width='100%' border='0' cellspacing='2' cellpadding='0'>
        <tr>
          <td width='40%' height="19" align='center' valign='middle'><? if($idiom) echo"<font face='arial'  color='#ff0000' size='3'><b>SEARCH</font></a>"; ?></td>
          <td width='20%' height="19"><select name='type' onchange='activate(this.form)'>
            <option value='0'selected>Select</option>
            <option value='Apartment'>Apartments</option>
            <option value='Villa'>Villas</option>
         
          </select></td>
          <td width='10%' height="19"><select name='subcat' id='idsubcat' onchange='activate2(this.form)' style='WIDTH: 100px' disabled>
                  <option value='0' selected>Select</option>
                  <option value='referencia'>reference</option>
                  <option value='rooms'>Room/option>
                  <option value='county'>County</option>
                    <option value='city'>City</option>
                  <option value='state'>State</option>
                  <option value='view'>Views</option>
                  <option value='price'>Price</option>
             </select></td>
          <td width='6%' height="19"><table width='100%' border='0' cellspacing='0' cellpadding='0' id='text' style='display:block'>
            <tr>
              <td><input name='search' type='text'  id='txtview' style='WIDTH: 100px' onFocus='delete(this.form)' size='10'></td>
            </tr>
          </table>
            <table width='100%' border='0' cellspacing='0' cellpadding='0' id='cbviews' style='display:none'>
              <tr>
                <td><select name='views'>
                    <option value='0'selected="selected">Select</option>
                    <option value='Mar'>Sea View</option>
                    <option value='Cidade'>City</option>
                    </select></td>
              </tr>
            </table>
            <table width='100%' border='0' cellspacing='2' cellpadding='0' id='prices' style='display:none'>
              <tr>
                <td><select name='min'>
                    <option value='0'selected="selected">Min:</option>
                    <option value='25000'>25000</option>
                    <option value='50000'>50000</option>
                    <option value='75000'>75000</option>
                    <option value='100000'>100000</option>
                 
                </select></td>
                <td align='center' valign='middle'><font face='arial narrow' color='#000000' size='1'>Betweenn</font></td>
                <td><select name='max'>
                    <option value='0'selected="selected">Max:</option>
                    <option value='25000'>25000</option>
                    <option value='50000'>50000</option>
                    <option value='75000'>75000</option>
                    <option value='100000'>100000</option>
               
                </select></td>
              </tr>
            </table></td>
          <td width='76%' height="19" align='left' valign='middle'><input type='image' src='images/sh.jpg' id='idbt1' disabled  onclick='send(this.form)' style='border:none'></td>
        </tr>
      </table>
    </form>
 
</body>
</html>
It is working fine, but I need more fields like the one in the attachment.
Conditions:

1 The user MUSTat least select field "BUSINESS" "TYPE" before submit.
2 The search can give results if the user selects or not any other fields.
3 I Have already lists of countres and their States with the cities. Is not shown at the next script due te lenght of it. But the FIELD "county" must be empty to the user enter the name of it. Of course it will save in database and next time that specific county it will appear.

I belive that you understand.


Unless ther out there any script that I can use.

thanks people.
Attached Files
File Type: txt search.txt (5.8 KB, 2 views)
josil is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-20-2010, 12:26 AM Re: Multi Fields Search Form
Average Talker

Posts: 15
Trades: 0
would you be kind to break down the tasks. It takes too much time to read and debug your code. It would be best if you can show us where is the drop down for:
1/ "BUSINESS" "TYPE" (html)
2 Validation function on submit that requires at least one

you can't just dump a bunch of code and expect people to debug and fix the code for you, we are helping not doing your work. Let's take one step at the time.
__________________

Please login or register to view this content. Registration is FREE
AskTechGuy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Multi Fields Search Form
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10282 seconds with 13 queries