Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- city dropdown
- <div class="form-group">
- <label for="">City</label>
- <select name="ct" id="ct" onChange="getPin()" class="form-control">
- <option value="0">Select City</option>
- </select>
- <span id="error11" class="alert-danger"></span>
- </div>
- When I am trying to fetch Pincode according to the selected city, It's
- not working. Below is the file where I need to bring value. Do I need to
- write value inside input text box to show the Pincode.
- Pincode Inputbox
- <div class="form-group">
- <label for="">Pin</label>
- <input type="text" class="form-control" name="pn" id="pin"
- autocomplete="off">
- <span id="error12" class="alert-danger"></span>
- </div>
- Ajax fetch Pincode
- function getPin()
- {
- var ct=document.getElementById('ct').value;
- var p;
- if(window.XMLHttpRequest)
- {
- p=new XMLHttpRequest();
- }
- else
- {
- p=new ActiveXObject("Microsoft.XMLHTTP");
- }
- p.open("POST","pin.php?ct_id="+ct,true);
- p.send();
- p.onreadystatechange=function()
- {
- if(p.readyState==4)
- {
- document.getElementById('pin').value=p.responseText;
- }
- }
- }
- pin.php page
- <?php
- include('connection.php');
- if(isset($_POST['ct_id']))
- {
- $ctid=$_POST['ct_id'];
- $pin_db="select * from pincode where cityId='$ctid'";
- $pin_db_exe=$con->query($pin_db) or mysqli_error();
- $ftch_pin=$pin_db_exe->fetch_array();
- print_r($ftch_pin);
- }
- ?>
- When I am selecting the city, in Pincode input text its showing error.
- Please need some help.
- <p><br>Success</p><br>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement