How to add prefix code on change event dropdown
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
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_baranginput field has a value likestmtand you want when you changeid_jenisdropdown for thekode_baranginput value to change toprefix stmt?
– Alex
Nov 19 '18 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 '18 at 2:01
sounds like you want to change the prefix not suffix as your question suggests. where isPRINandPCcoming from? is that the dropdown item name? further where is001coming from?
– Alex
Nov 19 '18 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 '18 at 14:13
sounds like you'll need ajax askode_barangis dependent/needs to be fetched based on the dropdown. do a simpleonchangejquery selector.
– Alex
Nov 22 '18 at 18:22
|
show 1 more comment
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 '18 at 7:44
Pathik Vejani
2,86323059
2,86323059
asked Nov 18 '18 at 12:09
Ahma-D-XCVAhma-D-XCV
1
1
If I'm understanding this correctly yourkode_baranginput field has a value likestmtand you want when you changeid_jenisdropdown for thekode_baranginput value to change toprefix stmt?
– Alex
Nov 19 '18 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 '18 at 2:01
sounds like you want to change the prefix not suffix as your question suggests. where isPRINandPCcoming from? is that the dropdown item name? further where is001coming from?
– Alex
Nov 19 '18 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 '18 at 14:13
sounds like you'll need ajax askode_barangis dependent/needs to be fetched based on the dropdown. do a simpleonchangejquery selector.
– Alex
Nov 22 '18 at 18:22
|
show 1 more comment
If I'm understanding this correctly yourkode_baranginput field has a value likestmtand you want when you changeid_jenisdropdown for thekode_baranginput value to change toprefix stmt?
– Alex
Nov 19 '18 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 '18 at 2:01
sounds like you want to change the prefix not suffix as your question suggests. where isPRINandPCcoming from? is that the dropdown item name? further where is001coming from?
– Alex
Nov 19 '18 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 '18 at 14:13
sounds like you'll need ajax askode_barangis dependent/needs to be fetched based on the dropdown. do a simpleonchangejquery selector.
– Alex
Nov 22 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 at 18:22
|
show 1 more comment
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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_baranginput field has a value likestmtand you want when you changeid_jenisdropdown for thekode_baranginput value to change toprefix stmt?– Alex
Nov 19 '18 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 '18 at 2:01
sounds like you want to change the prefix not suffix as your question suggests. where is
PRINandPCcoming from? is that the dropdown item name? further where is001coming from?– Alex
Nov 19 '18 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 '18 at 14:13
sounds like you'll need ajax as
kode_barangis dependent/needs to be fetched based on the dropdown. do a simpleonchangejquery selector.– Alex
Nov 22 '18 at 18:22