I'am looking for a hide show script based on parentCatId and catId!
This is the div i try to hide and or show! div class="item-post-lot-area"
<div class="item-post-lot-area">
<label for="s_lotsize">
<?php _e('Lot Area', 'ctg_housing'); ?>
</label>
<div class="row collapse prefix-radius">
<div class="item-post-area-sign columns">
<span class="prefix"><?php echo osc_get_preference('metric','ctg_housing_theme'); ?></span>
</div>
<div class="item-post-area-number columns">
<input type="number" name="s_lotsize" id="s_lotsize" value="<?php if(isset($housingOut['s_lotsize'])) { echo $housingOut['s_lotsize'];} ?>" >
</div>
</div>
</div>
what i try!
item-post-lot-area field will all time show when loading the page! And will hide when selected the following parentCatId and catId
<option value="28">Vacation</option>
<select id="catId" name="catId" class="valid">
<option value="28">Select Subcategory</option>
<option value="29">Pension House</option>
<option value="30">Inn / Motel</option>
<option value="31">Hotel & Resort</option>
</option>
</select>
<select id="catId" name="catId" class="valid">
<option value="32">Select Subcategory</option>
<option value="33">Space</option>
<option value="34">Office</option>
<option value="35">BPO</option>
<option value="36">Economic</option>
</select>
Can someone explain me how to do this?
Thanks
You're probably looking along the lines of using .on("change") to run when the select element is changed. You can then check which value (if need be) has been selected, and then use $(".item-post-lot-area").hide() to hide the div.
$("#catId").on("change", function(){
$(".item-post-lot-area").hide();
});
Related
I'm having some trouble passing the value of some HTML elements to PHP variable. I have a PHP web app where I give the users some drop down option. What I want to do is after the user has selected the option I give than to click on a button and make some calculations based on his/her selection.
I have tried using the POST and GET method but because I'm new to php I probably did it wrong. I also try with ids but no results.
Here is the HTML code
The 1st dropdown menu :
<div>
<select id="kleidwma" onchange="kleidwmata_change(this.value);kwdikos();ypsos();"
class="form-control selectpicker kleidwmata" data-size="10" data-
style="btn-white" name="guard_kleidwmata" required >
<option value="" > </option>
<option value="12">12 MS</option>
<option value="14">14 KETE</option>
<option value="15">15 ARRIKTON</option>
<option value="16">16 KETE</option>
<option value="22">22 KETE</option>
</select>
</div>
The 2nd dropdown menu :
<div>
<select id="sigkratisi" onchange="kwdikos()" name="sigkratisi"
class="form-control sigkratisi" required>
<option value="" ></option>
<option value="metalliki" >Μεταλλική</option>
<option value="xilogonia" >Ξυλογωνία</option>
</select>
</div>
Here is the button to be clicked after the selection has been made :
<div class="row" style="margin-top:20px; margin-left: 235px;">
<div class="col-md-7">
<input type="hidden" name="tmp_calculate" value="pending" />
<button onclick="calculate()" type="button" class="btn btn-success" >
<?php echo "Υπολογισμός";?></button>
</div>
</div>
And finally here is the function that is called :
function calculate()
{
$var1 = sigkratisi;
$var2 = kleidwma;
"code to be executed base on the var1 and var2"
}
I hope it's clear enough.
Thanks in advance for your time
you can use Forms
<form name="f" action="" method="POST">
<div>
<select id="kleidwma" name="variable"
class="form-control selectpicker kleidwmata" data-size="10" data-
style="btn-white" name="guard_kleidwmata" required >
<option value="" > </option>
<option value="12">12 MS</option>
<option value="14">14 KETE</option>
<option value="15">15 ARRIKTON</option>
<option value="16">16 KETE</option>
<option value="22">22 KETE</option>
</select>
<input type="submit" value="submit" />
</div>
</form>
in PHP
<?php
if(isset($_POST['variable']))
{
echo $_POST['variable'];
}
?>
Here i have two fields such as follows
<div class="left_2 two">
<select name="abc_type" id="abc_type_2" class="form-control">
<option value="AB">LSK-AB</option>
<option value="AC">LSK-AC</option>
<option value="BC">LSK-BC</option>
</select>
</div>
<div class="left_2 one">
<select name="abc_type" id="abc_type_1" class="form-control">
<option value="A">LSK-A</option>
<option value="B">LSK-B</option>
<option value="C">LSK-C</option>
</select>
</div>
i will be using only one field at a time and the remaining field will be hidden and the problem am always getting the value A which is present in second select tag while getting submitted.how can i pass the correct value which i choosed
Here is the solution what ever field will be hidden add disabled in the input field Check the code below.
<?php
if(isset($_POST['abc_type'])){
echo $_POST['abc_type'];
}
?>
<form action="" method="post">
<div class="left_2 two">
<select name="abc_type" id="abc_type_2" class="form-control">
<option value="AB">LSK-AB</option>
<option value="AC">LSK-AC</option>
<option value="BC">LSK-BC</option>
</select>
</div>
<div class="left_2 one">
<select name="abc_type" id="abc_type_1" class="form-control">
<option value="A">LSK-A</option>
<option value="B">LSK-B</option>
<option value="C">LSK-C</option>
</select>
</div>
<input type="submit" name="submit" value="submit"/>
</form>
I am trying to get user selection from php form but instead of name I am getting id of elements. instead of ids I want to get names. Please help
here is the url
http://efinancec.com/d/drop4/index.php
and here is the code
<form action="../form/form1.php" method="post" enctype="multipart/form-data">
<div class="frmDronpDown">
<div class="row">
<label>Training:</label><br/>
<select name="training" id="training-list" class="demoInputBox" onChange="getCourse(this.value);">
<option value="">Select Training</option>
<?php
foreach($results as $training) {
?>
<option value="<?php echo $training["id"]; ?>"><?php echo $training["training"]; ?></option>
<?php
}
?>
</select>
</div>
<div class="row">
<label>Course:</label><br/>
<select name="course" id="course-list" class="demoInputBox" onChange="getCountry(this.value);">
<option value="">Select Course</option>
</select>
</div>
<div class="row">
<label>Country:</label><br/>
<select name="country" id="country-list" class="demoInputBox" onChange="getCity(this.value);">
<option value="">Select Country</option>
</select>
</div>
<div class="row">
<label>City:</label><br/>
<select name="city" id="city-list" class="demoInputBox" onChange="getDates(this.value);">
<option value="">Select City</option>
</select>
</div>
<div class="row">
<label>Dates:</label><br/>
<select name="dates" id="dates-list" class="demoInputBox" onChange="getPrice(this.value);">
<option value="">Select Dates</option>
</select>
</div>
<div class="row">
<label>Online Onsite Price:</label><br/>
<select name="price" id="price-list" class="demoInputBox">
<option value="">Select Online or Onsite</option>
</select>
</div>
<input id="submit" name="submit" type="submit" value="Submit">
</form>
and this is how I am getting the values from sql database
<?php
require_once("dbcontroller.php");
$db_handle = new DBController();
if(!empty($_POST["training_id"])) {
$query ="SELECT * FROM course WHERE training_id = '" . $_POST["training_id"] . "'";
$results = $db_handle->runQuery($query);
?>
<option value="">Select Course</option>
<?php
foreach($results as $course) {
?>
<option value="<?php echo $course["id"]; ?>"><?php echo $course["course"]; ?></option>
<?php
}
}
?>
Change this line:
onChange="getCourse(this.value);">
To this :
onChange="getCourse(this.text);">
You are passing id of the course as the value of dropdown and calling that value which is fine but you need to call the text of select option to get the course name.
I changed this.value to this.text as suggested and created the new page and it stoped working at all now it is not pulling the records from database except the first one. Here is the link
http://efinancec.com/d/drop4/index1.php
where as my earlier page is still working fine.
http://efinancec.com/d/drop4/index.php
I think I could not convey my problem earlier. My depended dropdown is working fine but when a user submits the form in the email I receive the ids instead of name. Thats the problem.
For example I myself made some selections on index.php and submitted form Here is the email I got
training: 1
course : 101
country: 1001
city: 5005
Basically I am getting the the respective ids instead of name.
I have 2 questions if the answer to the first question is 1> I want the next answer to be auto populated as Yes. Can someone steer me in the right direction please?
<div class="field">
<!-- Number of Employees -->
<label>Number of Employees</label>
<div class="styled-select">
<select name="NoOfEmployees" class="validate[required]" data-prompt-position="topLeft:110,15">
<option value="">Please select</option>
<?php
foreach (range(0, 49) as $number) {
echo '<option value="'.$number.'">'.$number.'</option>';
}
?>
<option value="50 Plus">50+</option>
</select>
</div>
</div>
<div class="field">
<!-- Employers Liability Cover Required -->
<label>Employers Liability Cover Required</label>
<div class="styled-select">
<select name="EmployersLiabilityCover" class="validate[required]" data-prompt-position="topLeft:110,15">
<option value="">Please select</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div>
</div>
If the answer is 0 then I just need the next question to stay as Please Select.
use jquery onchange , give selectbox inputs seperate id,
Use jquery val() to get selectbox value
use if condition to check its greater than 0
code shown below
<div class="field">
<!-- Number of Employees -->
<label>Number of Employees</label>
<div class="styled-select">
<select name="NoOfEmployees" class="validate[required]" id="select1" data-prompt-position="topLeft:110,15">
<option value="">Please select</option>
<?php
foreach (range(0, 49) as $number) {
echo '<option value="'.$number.'">'.$number.'</option>';
}
?>
<option value="50 Plus">50+</option>
</select>
</div>
</div>
<div class="field">
<!-- Employers Liability Cover Required -->
<label>Employers Liability Cover Required</label>
<div class="styled-select">
<select name="EmployersLiabilityCover" id="select2" class="validate[required]" data-prompt-position="topLeft:110,15">
<option value="">Please select</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div>
</div>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script>
$('#select1').on('change', function() {
if(this.value>0)
{
$("#select2").val("Yes");
}
else
{
$("#select2").val("");
}
});
</script>
I'm currently creating a real estate's website, although I'm familiar with html, I could use some hints about using the php on the following:
How could I link a search form and dropdown menus on a left column to display the results on a right column.
How could I use the pagination in conjunction with the php script made to display the results.
How can I make the results appear in accordance with my css styles for the displayed results.
I've searched a ton of tutorials and got the most results on how to create a search engine but without css styling or dropdown menus. I've attached an image of my layout to make it easier to understand.
Any tips on where to start or basic logic behind the setup would be helpful.
Image: http://postimg.org/image/5j2naarh3/
Html:
<div class="w-clearfix main">
<div class="search">
<div class="param">
<div class="w-form">
<form name="email-form" data-name="Email Form">
<h2 class="h2">Find Properties</h2>
<input class="w-input dropdown" type="text" placeholder="Type your keywords" name="search" data-name="search"></input>
<select class="w-select dropdown" name="property-type" data-name="property-type">
<option value="">Property Type</option>
<option value="First">Apartment</option>
<option value="Second">Villa</option>
<option value="Third">Land-only</option>
<option value="fourth">Commercial \ Office</option>
<option value="fifth">Chateau \ Mansion</option>
<option value="sixth">Country Home</option>
<option value="seventh">Loft</option>
<option value="eighth">Equestrian</option>
<option value="nineth">Golf</option>
<option value="tenth">Vineyard</option>
<option value="eleventh">Other</option>
</select>
<select class="w-select dropdown" name="dropdown">
<option value="">Choose Country</option>
<option value="pt">Portugal</option>
<option value="es">Spain</option>
</select>
<select class="w-select dropdown" name="dropdown">
<option value="">Choose City</option>
<option value="lx">Lisbon</option>
<option value="st">Setubal</option>
<option value="mt">Montemor</option>
</select>
<select class="w-select dropdown" name="dropdown">
<option value="">Price Range</option>
<option value="First">100.000 - 500.000 €</option>
<option value="Second">500.000 - 1.000.000 €</option>
<option value="Third">1.000.000 - 5.000.000 €</option>
</select>
<input class="w-button param_button" type="submit" value="Reset" data-wait="Please wait..."></input>
<input class="w-button param_button _2" type="submit" value="Submit" data-wait="Please wait..."></input>
</form>
<div class="w-form-done">
<p>Thank you! Your submission has been received!</p>
</div>
<div class="w-form-fail">
<p>Oops! Something went wrong while submitting the form :(</p>
</div>
</div>
</div>
</div>
<div class="results">
<div class="ind_result">
<div class="w-row">
<div class="w-col w-col-3 w-col-small-6 w-clearfix image">
<img class="image" src="images/3.jpg" alt="3.jpg">
</div>
<div class="w-col w-col-9 w-col-small-6 w-clearfix desc"><a class="title" href="#">Superb 5 room Apartment</a>
<h4 class="price">990 000 €</h4>
<h5 class="sub-title">Tróia - Setúbal</h5>
<p class="description">BOULOGNE, facing the woods, superb five rooms apartment opening from both sides on two large private terraces (53 m²) apartment. In perfect condition, and very functional plan is ideal: entrance, living room, kitchen, three bedrooms (a fourth
is possible), two bathrooms, two parking spaces and a cellar</p>
<img class="map" src="images/show_on_map_btn.png" alt="show_on_map_btn.png">
</div>
</div>
</div>