Welcome Guest, Not a member yet? Register   Sign In
value of 2nd dropdown not comming
#1

[eluser]Unknown[/eluser]
i get data from 1st view in 2nd one but not get data from 2nd view in 3rd one


I have a controller called iis like as
function bundlecard(){
$this->load->view('top');

$arrbuyer=$this->Bcm->buyer_drop();
foreach ($arrbuyer as $buyers) {
$arrfinal['']="--Select Buyer--";
$arrfinal[$buyers->buyer]=$buyers->buyer;
}
$data['buyer']=$arrfinal;

$this->load->view('bundlecard',$data);
$this->load->view('bottom');
}
function ajax_style() {
if (isset($_POST) && isset($_POST['buyer'])) {

$buyer['buyer'] = $_POST['buyer'];
if ($buyer!='') {
$this->load->view('style_drop',$buyer);
}

} else {
redirect('site'); //Else redire to the site home page.
}
}

function ajax_cunty() {
//Checking so that people cannot go to the page directly.
if (isset($_POST) && isset($_POST['style'])) {
$style['style'] = $_POST['style'];
if ($_POST['style']=='') {
echo "your style is nul".$_POST['style'];
}


else {
echo "your style is:-".$_POST['style'];
}

if ($style!='') {
$this->load->view('cunty_drop',$style);
}
} else {
redirect('site'); //Else redire to the site home page.
}
}

View1 (bundlecard):-

[removed]
$(document).ready(function () {
$('#buyers-dropdown').change(function () {
var selbuyer = $('#buyers-dropdown').val();
console.log(selbuyer);
$.ajax({
url: "<?php echo $base?>/index.php/iis/ajax_style", //The url where the server req would we made.
async: false,
type: "POST", //The type which you want to use: GET/POST
data: "buyer="+selbuyer, //The variables which are going.
dataType: "html", //Return data type (what we expect).
success: function(data) { //This is the function which will be called if ajax call is successful.
//data is the html of the page where the request is made.
$('#style').html(data);
}
})
});
});
[removed]


<div class="row">
<div class="span4">
<div class="well">

<center> <h5> Data Entry For Bundle Card </h3></center>

&lt;?php echo form_open() ?&gt;
<div id="wrapper">

&lt;?php echo form_dropdown('buyer', $buyer, '', 'id="buyers-dropdown"'); ?&gt;

<div id="style"></div>
<div id="cunty"></div>
<div id="colour"></div>
</div>
</div>
</div>
</div>


&lt;?php echo form_close() ?&gt;
View 2(style_drop):-

&lt;!-- start send buyer to get style --&gt;
[removed]
$(document).ready(function () {
$('#style').change(function () {
//var selstyle = $(this).attr('value');
//var selstyle = $(this).val();
var selstyle = "st";
var selstyle = $('#style').val();
console.log(selstyle);
$.ajax({
url: "http://localhost/rtiis/index.php/iis/ajax_cunty",
// url: "http://localhost/rtiis/index.php/iis/ajax_colour",
async: false,
type: "POST", //The type which you want to use: GET/POST
data: "style="+selstyle, //The variables which are going.
dataType: "html", //Return data type (what we expect).
success: function(data) { //This is the function which will be called if ajax call is successful.
//data is the html of the page where the request is made.
$('#cunty').html(data);
}
})
});
});
[removed]
&lt;!--end send buyer to get style --&gt;
&lt;?php
echo $buyer;
$arrstyles = $this->Bcm->get_style($buyer);
if ($arrstyles!='') { //checking is there any style of that buyer
?&gt;
<label for="style">Style</label>
<select name="style" id="style">
<option value=""></option>
&lt;?php
foreach($arrstyles as $styles){
echo '<option value="' . $styles-&gt;style . '">' . $styles->style . '</option>';
}

?&gt;
</select>
&lt;?php } ?&gt;
View 3(cunty_drop)

&lt;!-- start send buyer to get style --&gt;
[removed]
$(document).ready(function () {
$('#cunty').change(function () {
//var selbuyer = $(this).attr('value');
var selcunty = $(this).val();
console.log(selcunty);
$.ajax({
url: "http://localhost/rtiis/index.php/iis/ajax_colour",
async: false,
type: "POST", //The type which you want to use: GET/POST
data: "cunty="+selcunty, //The variables which are going.
dataType: "html", //Return data type (what we expect).
success: function(data) { //This is the function which will be called if ajax call is successful.
//data is the html of the page where the request is made.
$('#colour').html(data);
}
})
});
});
[removed]
&lt;!--end send buyer to get style --&gt;
&lt;?php $arrcuntys = $this->Bcm->cunty_drop();
if ($arrcuntys!='') { //checking is there any style of that buyer
?&gt;
<label for="cunty">Cunty</label>
<select name="cunty" id="cunty" >
<option value=""></option>
&lt;?php
foreach($arrcuntys as $cuntys){
echo '<option value="' . $cuntys-&gt;cunty . '">' . $cuntys->cunty . '</option>';
}

?&gt;
</select> &lt;?php } ?&gt;
#2

[eluser]InsiteFX[/eluser]
Please wrap your code in code tags, use REPLY POST for full editor.




Theme © iAndrew 2016 - Forum software by © MyBB