How to add prefix code on change event dropdown
up vote
0
down vote
favorite
Hi I'm new in codeigniter so this is the problem
I want to add prefix to textbox based on selected value in dropdown menu here's the source
In Controller
function index(){
$data['title'] = 'SIPPERTIKOMPPAK|Input Barang';
$data2 =array(
'kode_barang' => $this->m_master->kode_barang(),
'get_lokasi' => $this->m_master->get_lokasi(),
'get_jenis' => $this->m_master->get_jenis()
);
$this->load->view('backend/preload/meta',$data);
$this->load->view('backend/preload/head');
$this->load->view('backend/preload/sidebar');
$this->load->view('backend/master/v_masterb',($data2));
}
In Model
function kode_barang(){
$kode= $this->db->select_max('id_barang')->get('tb_master_barang')->result_array();
$qkode = array();
foreach($kode as $r) {
$qkode = $r['id_barang']+1;
}
$qkode=str_pad($qkode,3, '0' , STR_PAD_LEFT);
// $qqkode = 'PRINJ'.$qkode;
return $qkode;
}
In View
<div class="form-group">
<label for="kode_barang">Kode Barang</label>
<input type="text" class="form-control" name="kode_barang" value="<?php echo $kode_barang; ?>" readonly />
</div>
<div class="form-group">
<label for="get_jenis">Jenis Barang</label>
<?php echo form_dropdown('id_jenis', $get_jenis, '', 'class="form-control"');?>
</div>
I want to add prefix to textbox for example like this
if id_jenis ==1
textbox.value = 'Prefix'+($qkode value from model)
else
textbox.value = 'Prefix'+($qkode value from model)
codeigniter dropdown onchange prefix
|
show 1 more comment
up vote
0
down vote
favorite
Hi I'm new in codeigniter so this is the problem
I want to add prefix to textbox based on selected value in dropdown menu here's the source
In Controller
function index(){
$data['title'] = 'SIPPERTIKOMPPAK|Input Barang';
$data2 =array(
'kode_barang' => $this->m_master->kode_barang(),
'get_lokasi' => $this->m_master->get_lokasi(),
'get_jenis' => $this->m_master->get_jenis()
);
$this->load->view('backend/preload/meta',$data);
$this->load->view('backend/preload/head');
$this->load->view('backend/preload/sidebar');
$this->load->view('backend/master/v_masterb',($data2));
}
In Model
function kode_barang(){
$kode= $this->db->select_max('id_barang')->get('tb_master_barang')->result_array();
$qkode = array();
foreach($kode as $r) {
$qkode = $r['id_barang']+1;
}
$qkode=str_pad($qkode,3, '0' , STR_PAD_LEFT);
// $qqkode = 'PRINJ'.$qkode;
return $qkode;
}
In View
<div class="form-group">
<label for="kode_barang">Kode Barang</label>
<input type="text" class="form-control" name="kode_barang" value="<?php echo $kode_barang; ?>" readonly />
</div>
<div class="form-group">
<label for="get_jenis">Jenis Barang</label>
<?php echo form_dropdown('id_jenis', $get_jenis, '', 'class="form-control"');?>
</div>
I want to add prefix to textbox for example like this
if id_jenis ==1
textbox.value = 'Prefix'+($qkode value from model)
else
textbox.value = 'Prefix'+($qkode value from model)
codeigniter dropdown onchange prefix
If I'm understanding this correctly yourkode_barang
input field has a value likestmt
and you want when you changeid_jenis
dropdown for thekode_barang
input value to change toprefix stmt
?
– Alex
Nov 19 at 0:37
yes something like that for example if I change id_jenis dropdown == 1 then in kode_barang input field will change to PRINJ001 and if I change it to id_jenis == 2 then in kode_barang input field will change to PC001 something like that
– Ahma-D-XCV
Nov 19 at 2:01
sounds like you want to change the prefix not suffix as your question suggests. where isPRIN
andPC
coming from? is that the dropdown item name? further where is001
coming from?
– Alex
Nov 19 at 7:33
Dropdown is list of item group like printer, pc, hdd, LCD, LED, etc and I want in kode_barahg textbox value to change according to the group chosen from dropdown menu for example if user choose PC then in textbox value change to PC001 and 001 come from select max query from one of the table which name is tb_master_barang in the database
– Ahma-D-XCV
Nov 22 at 14:13
sounds like you'll need ajax askode_barang
is dependent/needs to be fetched based on the dropdown. do a simpleonchange
jquery selector.
– Alex
Nov 22 at 18:22
|
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Hi I'm new in codeigniter so this is the problem
I want to add prefix to textbox based on selected value in dropdown menu here's the source
In Controller
function index(){
$data['title'] = 'SIPPERTIKOMPPAK|Input Barang';
$data2 =array(
'kode_barang' => $this->m_master->kode_barang(),
'get_lokasi' => $this->m_master->get_lokasi(),
'get_jenis' => $this->m_master->get_jenis()
);
$this->load->view('backend/preload/meta',$data);
$this->load->view('backend/preload/head');
$this->load->view('backend/preload/sidebar');
$this->load->view('backend/master/v_masterb',($data2));
}
In Model
function kode_barang(){
$kode= $this->db->select_max('id_barang')->get('tb_master_barang')->result_array();
$qkode = array();
foreach($kode as $r) {
$qkode = $r['id_barang']+1;
}
$qkode=str_pad($qkode,3, '0' , STR_PAD_LEFT);
// $qqkode = 'PRINJ'.$qkode;
return $qkode;
}
In View
<div class="form-group">
<label for="kode_barang">Kode Barang</label>
<input type="text" class="form-control" name="kode_barang" value="<?php echo $kode_barang; ?>" readonly />
</div>
<div class="form-group">
<label for="get_jenis">Jenis Barang</label>
<?php echo form_dropdown('id_jenis', $get_jenis, '', 'class="form-control"');?>
</div>
I want to add prefix to textbox for example like this
if id_jenis ==1
textbox.value = 'Prefix'+($qkode value from model)
else
textbox.value = 'Prefix'+($qkode value from model)
codeigniter dropdown onchange prefix
Hi I'm new in codeigniter so this is the problem
I want to add prefix to textbox based on selected value in dropdown menu here's the source
In Controller
function index(){
$data['title'] = 'SIPPERTIKOMPPAK|Input Barang';
$data2 =array(
'kode_barang' => $this->m_master->kode_barang(),
'get_lokasi' => $this->m_master->get_lokasi(),
'get_jenis' => $this->m_master->get_jenis()
);
$this->load->view('backend/preload/meta',$data);
$this->load->view('backend/preload/head');
$this->load->view('backend/preload/sidebar');
$this->load->view('backend/master/v_masterb',($data2));
}
In Model
function kode_barang(){
$kode= $this->db->select_max('id_barang')->get('tb_master_barang')->result_array();
$qkode = array();
foreach($kode as $r) {
$qkode = $r['id_barang']+1;
}
$qkode=str_pad($qkode,3, '0' , STR_PAD_LEFT);
// $qqkode = 'PRINJ'.$qkode;
return $qkode;
}
In View
<div class="form-group">
<label for="kode_barang">Kode Barang</label>
<input type="text" class="form-control" name="kode_barang" value="<?php echo $kode_barang; ?>" readonly />
</div>
<div class="form-group">
<label for="get_jenis">Jenis Barang</label>
<?php echo form_dropdown('id_jenis', $get_jenis, '', 'class="form-control"');?>
</div>
I want to add prefix to textbox for example like this
if id_jenis ==1
textbox.value = 'Prefix'+($qkode value from model)
else
textbox.value = 'Prefix'+($qkode value from model)
codeigniter dropdown onchange prefix
codeigniter dropdown onchange prefix
edited Nov 20 at 7:44
Pathik Vejani
2,86622958
2,86622958
asked Nov 18 at 12:09
Ahma-D-XCV
1
1
If I'm understanding this correctly yourkode_barang
input field has a value likestmt
and you want when you changeid_jenis
dropdown for thekode_barang
input value to change toprefix stmt
?
– Alex
Nov 19 at 0:37
yes something like that for example if I change id_jenis dropdown == 1 then in kode_barang input field will change to PRINJ001 and if I change it to id_jenis == 2 then in kode_barang input field will change to PC001 something like that
– Ahma-D-XCV
Nov 19 at 2:01
sounds like you want to change the prefix not suffix as your question suggests. where isPRIN
andPC
coming from? is that the dropdown item name? further where is001
coming from?
– Alex
Nov 19 at 7:33
Dropdown is list of item group like printer, pc, hdd, LCD, LED, etc and I want in kode_barahg textbox value to change according to the group chosen from dropdown menu for example if user choose PC then in textbox value change to PC001 and 001 come from select max query from one of the table which name is tb_master_barang in the database
– Ahma-D-XCV
Nov 22 at 14:13
sounds like you'll need ajax askode_barang
is dependent/needs to be fetched based on the dropdown. do a simpleonchange
jquery selector.
– Alex
Nov 22 at 18:22
|
show 1 more comment
If I'm understanding this correctly yourkode_barang
input field has a value likestmt
and you want when you changeid_jenis
dropdown for thekode_barang
input value to change toprefix stmt
?
– Alex
Nov 19 at 0:37
yes something like that for example if I change id_jenis dropdown == 1 then in kode_barang input field will change to PRINJ001 and if I change it to id_jenis == 2 then in kode_barang input field will change to PC001 something like that
– Ahma-D-XCV
Nov 19 at 2:01
sounds like you want to change the prefix not suffix as your question suggests. where isPRIN
andPC
coming from? is that the dropdown item name? further where is001
coming from?
– Alex
Nov 19 at 7:33
Dropdown is list of item group like printer, pc, hdd, LCD, LED, etc and I want in kode_barahg textbox value to change according to the group chosen from dropdown menu for example if user choose PC then in textbox value change to PC001 and 001 come from select max query from one of the table which name is tb_master_barang in the database
– Ahma-D-XCV
Nov 22 at 14:13
sounds like you'll need ajax askode_barang
is dependent/needs to be fetched based on the dropdown. do a simpleonchange
jquery selector.
– Alex
Nov 22 at 18:22
If I'm understanding this correctly your
kode_barang
input field has a value like stmt
and you want when you change id_jenis
dropdown for the kode_barang
input value to change to prefix stmt
?– Alex
Nov 19 at 0:37
If I'm understanding this correctly your
kode_barang
input field has a value like stmt
and you want when you change id_jenis
dropdown for the kode_barang
input value to change to prefix stmt
?– Alex
Nov 19 at 0:37
yes something like that for example if I change id_jenis dropdown == 1 then in kode_barang input field will change to PRINJ001 and if I change it to id_jenis == 2 then in kode_barang input field will change to PC001 something like that
– Ahma-D-XCV
Nov 19 at 2:01
yes something like that for example if I change id_jenis dropdown == 1 then in kode_barang input field will change to PRINJ001 and if I change it to id_jenis == 2 then in kode_barang input field will change to PC001 something like that
– Ahma-D-XCV
Nov 19 at 2:01
sounds like you want to change the prefix not suffix as your question suggests. where is
PRIN
and PC
coming from? is that the dropdown item name? further where is 001
coming from?– Alex
Nov 19 at 7:33
sounds like you want to change the prefix not suffix as your question suggests. where is
PRIN
and PC
coming from? is that the dropdown item name? further where is 001
coming from?– Alex
Nov 19 at 7:33
Dropdown is list of item group like printer, pc, hdd, LCD, LED, etc and I want in kode_barahg textbox value to change according to the group chosen from dropdown menu for example if user choose PC then in textbox value change to PC001 and 001 come from select max query from one of the table which name is tb_master_barang in the database
– Ahma-D-XCV
Nov 22 at 14:13
Dropdown is list of item group like printer, pc, hdd, LCD, LED, etc and I want in kode_barahg textbox value to change according to the group chosen from dropdown menu for example if user choose PC then in textbox value change to PC001 and 001 come from select max query from one of the table which name is tb_master_barang in the database
– Ahma-D-XCV
Nov 22 at 14:13
sounds like you'll need ajax as
kode_barang
is dependent/needs to be fetched based on the dropdown. do a simple onchange
jquery selector.– Alex
Nov 22 at 18:22
sounds like you'll need ajax as
kode_barang
is dependent/needs to be fetched based on the dropdown. do a simple onchange
jquery selector.– Alex
Nov 22 at 18:22
|
show 1 more comment
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53360702%2fhow-to-add-prefix-code-on-change-event-dropdown%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If I'm understanding this correctly your
kode_barang
input field has a value likestmt
and you want when you changeid_jenis
dropdown for thekode_barang
input value to change toprefix stmt
?– Alex
Nov 19 at 0:37
yes something like that for example if I change id_jenis dropdown == 1 then in kode_barang input field will change to PRINJ001 and if I change it to id_jenis == 2 then in kode_barang input field will change to PC001 something like that
– Ahma-D-XCV
Nov 19 at 2:01
sounds like you want to change the prefix not suffix as your question suggests. where is
PRIN
andPC
coming from? is that the dropdown item name? further where is001
coming from?– Alex
Nov 19 at 7:33
Dropdown is list of item group like printer, pc, hdd, LCD, LED, etc and I want in kode_barahg textbox value to change according to the group chosen from dropdown menu for example if user choose PC then in textbox value change to PC001 and 001 come from select max query from one of the table which name is tb_master_barang in the database
– Ahma-D-XCV
Nov 22 at 14:13
sounds like you'll need ajax as
kode_barang
is dependent/needs to be fetched based on the dropdown. do a simpleonchange
jquery selector.– Alex
Nov 22 at 18:22