I have simple select for gender option :
<select class="form-control show-tick" name="kelamin" required="true">
<option value="">-- Please select --</option>
<option value="L" >Laki-Laki</option>
<option value="P">Perempuan</option>
</select>
How to set_value on select option like
<input type="text" name="nama" class="form-control" value="<?= set_value('nama'); ?>" required="true">
Use the set_select function.
<select class="form-control show-tick" name="kelamin" required="true">
<option value="" <?= set_select('kelamin', '', TRUE); ?> >-- Please select --</option>
<option value="L" <?= set_select('kelamin', 'L'); ?> >Laki-Laki</option>
<option value="P" <?= set_select('kelamin', 'P'); ?> >Perempuan</option>
</select>
Related
I am trying to make it available that user select more than option:
<select class="custom-select" form-control" multiple>
#foreach($permission_maps as $permission_map)
<option value="">{{$permission_map}}</option>
#endforeach
</select>
Only one option could be selected
Change the select tag to this:
<select class="custom-select form-control" multiple>
select name attribute should have the name of table column:
<select **name ="permissions[]"** class="custom-select form-control" multiple>
here column name is permissions
<select name="inputName[]" class="custom-select" form-control" multiple>
#foreach($permission_maps as $permission_map)
<option value="">{{$permission_map}}</option>
#endforeach
</select>
Can somebody help me? I have question. I have view, name is pascasarjana.php
<div class="form-group">
<label>Program studi dan konsentrasi yang diminati</label><br/>
<input name="prodis" type="checkbox" value="p1">Program Studi Magister Manajemen<br/>
</div>
<div class="form-group">
<input name="prodis" type="checkbox" value="p2">Program Studi Magister Teknik Sipil
<select name="konsentrasi" class="form-control" id="konsentrasi1">
<option value="">Pilih Konsentrasi</option>
<option value="k1">Manajemen Konstruksi</option>
<option value="k2">Transportasi</option>
<option value="k3">Struktur</option>
</select>
</div>
<div class="form-group">
<input name="prodis" type="checkbox" value="p3">Program Studi Magister Ilmu Hukum
<select name="konsentrasi" class="form-control" id="konsentrasi2">
<option value="">Pilih Konsentrasi</option>
<option value="k4">Hukum Bisnis</option>
<option value="k5">Hukum Ketatanegaraan</option>
<option value="k6">Hukum Agraria</option>
<option value="k7">Litigasi</option>
</select>
</div>
<div class="form-group">
<input name="prodis" type="checkbox" value="p4">Program Studi Magister Teknik Informatika
<select name="konsentrasi" class="form-control" id="konsentrasi3">
<option value="">Pilih Konsentrasi</option>
<option value="k8">Soft Computing</option>
<option value="k9">Enterprise Information System</option>
<option value="k10">Mobile Computing</option>
</select>
</div>
<div class="form-group">
<input name="prodis" type="checkbox" value="p5">Program Studi Magister Teknik Arsitektur
<select name="konsentrasi" class="form-control" id="konsentrasi4">
<option value="">Pilih Konsentrasi</option>
<option value="k11">Arsitektur Digital</option>
</select>
</div>
AND I confused, how to insert multiple checkbox and select option data to database in my controller and model.
Try renaming your HTML entities as arrays
Eg.
input name="prodis" to input name="prodis[]"
select name="konsentrasi" to select name="konsentrasi[]"
Then print $_POST in your controller.
I guess you need to get data from select box on the basis of ticked checkbox.
For getting values from checkbox you need to define checkbox name as an array. In my code I am using exact indexes so we can get select box values accordingly.
I guess below first checkbox there should be another select box. Ignoring this select box (Which is actually not here), I am giving custom indexes here. Instead, we also can use like profis[] which actually auto generate indexes by incrementing it one on each occurrence in HTML
You can implement validation too. Here are modified code:
<div class="form-group">
<label>Program studi dan konsentrasi yang diminati</label><br/>
<input name="prodis[1]" type="checkbox" value="p1">Program Studi Magister Manajemen<br/>
</div>
<div class="form-group">
<input name="prodis[2]" type="checkbox" value="p2">Program Studi Magister Teknik Sipil
<select name="konsentrasi[2]" class="form-control" id="konsentrasi1">
<option value="">Pilih Konsentrasi</option>
<option value="k1">Manajemen Konstruksi</option>
<option value="k2">Transportasi</option>
<option value="k3">Struktur</option>
</select>
</div>
<div class="form-group">
<input name="prodis[3]" type="checkbox" value="p3">Program Studi Magister Ilmu Hukum
<select name="konsentrasi[3]" class="form-control" id="konsentrasi2">
<option value="">Pilih Konsentrasi</option>
<option value="k4">Hukum Bisnis</option>
<option value="k5">Hukum Ketatanegaraan</option>
<option value="k6">Hukum Agraria</option>
<option value="k7">Litigasi</option>
</select>
</div>
<div class="form-group">
<input name="prodis[4]" type="checkbox" value="p4">Program Studi Magister Teknik Informatika
<select name="konsentrasi[4]" class="form-control" id="konsentrasi3">
<option value="">Pilih Konsentrasi</option>
<option value="k8">Soft Computing</option>
<option value="k9">Enterprise Information System</option>
<option value="k10">Mobile Computing</option>
</select>
</div>
<div class="form-group">
<input name="prodis[5]" type="checkbox" value="p5">Program Studi Magister Teknik Arsitektur
<select name="konsentrasi[5]" class="form-control" id="konsentrasi4">
<option value="">Pilih Konsentrasi</option>
<option value="k11">Arsitektur Digital</option>
</select>
At controller end you can just check if index 2 $this->input->post('prodis[2]') then get the value of select box with index 2 $this->input->post('konsentrasi[2]'
You can check it dynamically by keeping code redundancy in your mind. Let me know if you face any issue.
Insert Multiple data using check box or anything on HTML.Just use array "[]".
<input name="checkbox[]" type="checkbox" value="checkbox">
<select name="select[]"></select>
Can also array values like [2],[4],[5] anythings
Thank You
public function insert()
{
//Insert second stage details for employer into database.
$Specilized_category = $this->input->post('spec_cat');
$data=array(
'Specilized_category'=>json_encode(implode(",", $Specilized_category)),
);
$this->db->insert('tbl_employer', $data);
<select name="A">
<option value="1">Volvo</option>
<option value="2">Saab</option>
</select>
<select name="B">
<option value="1">test1</option>
<option value="2">test2</option>
</select>
<input type="Submit" >
After I submit, I want to show result from A and B. For example:
if($_POST['A']==1 && $_POST['B']==2){
echo 'true';
}else{
echo '0';
}
Is it possible to do this in joomla?
you have to enclosed this input fields into form tag. For example
<form method="post">
<select name="A">
<option value="1">Volvo</option>
<option value="2">Saab</option>
</select>
<select name="B">
<option value="1">test1</option>
<option value="2">test2</option>
</select>
<input type="Submit" >
</form>
Hope it will help
I'm trying to use a drop down list with a default value equals nothing
but nothing means zero and every time i try, it says that i cant divide by zero
how can i make the default value equal null not zero ?
<form method="post" action="try.php"name="test">
<select name="xx">
<option selected=""></option>
<option value="1">1</option>
<option value="3">3</option>
<option value="5">5</option>
<option value="7">7</option>
<option value="9">9</option>
</select>
<br /><input type="submit" name="submit" value="PROSES" />
</form>
<?php
if(isset($_POST['submit'])){
$x=$_POST['xx'];
$z=1/$x;
}
?>
I am trying make a register form adn using jquery validation. I have a problem.
I want only one "warning message" for "birthday select box"..I couldnt manage this and it look terrible when i get 3x warning for each bday select box. How can i give "one" warning message if at least one box not choosed?
And my codes are below, i made it short and working for test:
<script language="JavaScript" type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script language="JavaScript" type="text/javascript" src="js/jquery.validate.js"></script>
<script>
$(document).ready(function(){
$.validator.addMethod("username", function(value, element) {
return this.optional(element) || /^[a-z0-9\_]+$/i.test(value);
}, "Username must contain only letters, numbers, or underscore.");
$("#regForm").validate();
});
</script>
</head>
<body>
<div>
<form method="post" id="regForm" action="register.php">
<div>
Name<br>
<input id="user_name" name="name" type="text" minlength="5" class="required username"/><br>
</div>
<div>
E-mail<br>
<input id="usr_email3" name="email" type="text" class="required email"/><br>
</div>
<div>
Password<br>
<input name="pass1" type="password" class="required password" minlength="5" id="pwd" /><br>
</div>
<div>
Confirm Password<br>
<input id="pwd2" name="pass2" class="required password" type="password" minlength="5" equalto="#pwd" /><br>
</div>
<div>
Birthday:
<select name="birthday_day" class="required">
<option value="">Day</option>
<option value="1" >1</option>
<option value="2" >2</option>
</select>
<select name="birthday_month" class="required">
<option value="">Month</option>
<option value="1" >January</option>
</select>
<select name="birthday_year" class="required">
<option value="">Year</option>
<option value="1900" >1900</option>
</select>
</div>
<div>
Gender:
<select name="gender" class="required">
<option value="">Choose</option>
<option value="Male">Male</option>
<option value="Female">Female</option><br /></div>
<br>
<div>
<input id="doRegister" name="doRegister" type="submit" value="Send"/>
</div>
</form>
</div>
Give an id to the div surrounding the birthday tags:
<div id="required">
Birthday:
<select name="birthday_day" class="required">
<option value="">Day</option>
<option value="1" >1</option>
<option value="2" >2</option>
</select>
<select name="birthday_month" class="required">
<option value="">Month</option>
<option value="1" >January</option>
</select>
<select name="birthday_year" class="required">
<option value="">Year</option>
<option value="1900" >1900</option>
</select>
</div>
Use the code below to apply a red border if any of the select tags are not selected:
$('#doRegister').click(function(){
var a = $('select[name="birthday_day"]').val();
var b = $('select[name="birthday_month"]').val();
var c = $('select[name="birthday_year"]').val();
if(a == '' || b == '' || c == '')
{
$('div#required').css('border', '1px solid f60f60');
}
else
{
$('div#required').css('border', 'none');
}
});
This,of course, avoids the use of the validator plugin that you're using