【发布时间】:2014-06-25 10:39:50
【问题描述】:
国家/地区下拉列表中没有填充数据代码点火器,任何机构都可以帮助我,我想要查看国家/地区列表,以便我可以选择国家/地区。当我在视图中添加选择代码以进行下拉时,它会隐藏列表并保存按钮。
我的模特
public function get_Country() {
$this->db->select('code, name')->from("country");
$query = $this->db->get();
return $query->result_array();
}
我的控制器
public function get_Country() {
$ctry = $this->job_post_model->get_Country();
// debug($ctry);
}
我的查看代码
<div class="row">
<div class="span8">
<div class="about-heading">
<div class="head-menu"> </div>
</div>
<div class="about-section">
<div class="about-content rigs-content">
<form name="jobpost" action=" <?php echo base_url('employer/job_post/post_job'); ?>" method="post">
<h2>Your Job Detail :</h2>
<div class="invest-form">
<ul>
<li class="pull-right">
<label>Job Category:</label>
<input type="text" name="jobcat" value="" placeholder="Enter Job Category*" />
</li>
<li class="pull-right">
<label>Job Title:</label>
<input type="text" name="jobtitle" value="" placeholder="Enter Job Title*" />
</li>
<li>
<label>Job Type:</label>
<input type="text" name="jobtype" value="" placeholder="Enter Job Type*" />
</li>
<li class="pull-right">
<label>Preffered Age:</label>
<input type="text" name="age" value="" placeholder="Enter Job Title*" />
</li>
<li>
<label>Preffered Gender:</label>
<input type="text" name="gender" value="" placeholder="Enter Job Type*" />
</li>
<li>
<label>Job Description:</label>
<input type="text" name="desc" value="" placeholder="Enter Job Type*" />
</li>
<li class="pull-right">
<label>Location:</label>
<input type="text" name="location" value="" placeholder="Enter the Country*" />
</li>
<li>
<label>Post Code:</label>
<input type="text" id="post" rel="popover" data-trigger="hover" name="postcode" placeholder="Enter the City*" />
</li>
<li class="pull-right">
<label>Salary:</label>
<input type="text" id="salaries" name="salary" placeholder="Enter the Salary*" />
</li>
<li>
<li>
<label>Qualification:</label>
<input type="text" id="qualification" rel="popover" data-trigger="hover" name="qualification" placeholder="Enter Benifits*" />
</li>
<li class="pull-right">
<label>Category:</label>
<input type="text" id="category" class="span12" required name="category" placeholder="Enter Job Tags" />
</li>
<label>Benifits:</label>
<input type="text" id="benefits" rel="popover" data-trigger="hover" name="benefits" placeholder="Enter Benifits*" />
</li>
<li class="pull-right">
<label>Job Tags:</label>
<input type="text" id="jobtags" class="span12" required name="jobtag" placeholder="Enter Job Tags" />
</li>
<li class="pull-right">
<label>Career Level:</label>
<input type="text" id="career" class="span12" required name="career" placeholder="Enter Job Tags" />
</li>
<li>
<label>Country:</label>
<?php $countries = get_Country(); ?>
<select name="country">
<option>Select your country*</option>
<?php foreach ($countries as $country) { ?>
<option value="<?php echo $country->name ?>" </option>
<?php }
?>
</select>
</li>
<li class="pull-right">
<table id="question">
<th>Add Killer Questions</th>
<tr>
<td><input type="text" id="questions" name="question[]"/></td>
</tr>
</table>
<td><input type="button" id="btnAdd" class="button-add" onClick="insertTextBox()" value="Add More"></input></td>
</li>
<br>
<input type="submit" value="Save As Draft" class="button-next" />
</div>
</form>
<div class="wid-social">
</div>
</div>
</div>
</div>
<script>
var index = 1;
function insertTextBox(){
var text = document.getElementById("question");
var row=text.insertRow(text.rows.length);
var cell1=row.insertCell(0);
var t1=document.createElement("input");
t1.id = "question"+index;
t1.name = "question[]";
cell1.appendChild(t1);
var cell2=row.insertCell(1);
index++;
}
</script>
【问题讨论】:
-
你是如何加载视图文件的?
-
在 url 中写下这一行:localhost/ajobis/employer/job_post/post_job
-
我的意思是在控制器中。不错的答案:)
-
你没有关闭你的选项开始标签,在 ?>" 之后添加 >"。此外,你将国家作为数组返回,但访问它的键,就好像它是一个对象一样。你应该加载它们在控制器中然后传递给视图
-
您在视图中调用控制器的方式是
not correct,这也不是一个好习惯。您必须先填充数据,然后将其传递给您的视图。
标签: codeigniter