类型的下拉文本框包含两个选项 如
1.追踪网址+图片和2.代码。
如果我选择了跟踪网址+图片,那么我会添加两个选项跟踪网址和图片 然后我选择代码然后添加js_api_code
当我通过回叫验证检查跟踪网址是否已经存在时,错误是不可见的,跟踪网址和图片选项也是不可见的,最终用户不知道实际问题
此外,当我通过j查询验证验证它时,它不起作用
<form onsubmit="return checktrackingurl();" method="post" action="add_content" enctype="multipart/form-data" class="form-horizontal">
<div class="panel-body">
<input type="hidden" name="type" value="banner">
<div style="color:red;padding:5px;">
<?php echo form_error('content_type_id'); ?>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="form-field-3" >
Content Type<font color="red">*</font>
</label>
<div class="col-sm-5">
<select id="super_category_id" class="form-control" id="content_type_id" name='content_type_id' readonly>
<?php foreach($content_type as $content_type)
{ ?>
<option value="<?php echo $content_type['content_type_id']; ?>"><?php echo $content_type['content_type']; ?>
</option>
<?php } ?>
</select>
</div>
</div>
<div style="color:red;padding:5px;">
<?php echo form_error('title'); ?>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="form-field-3" >
Title<font color="red">*</font>
</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="title" name="title" placeholder="Title" value="<?php echo set_value('title'); ?>">
</div>
</div>
<div style="color:red;padding:5px;">
<?php echo form_error('selectwhat'); ?>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="form-field-3" >
Type <font color="red">*</font>
</label>
<div class="col-sm-5">
<select name="selectwhat" class="form-control" id="selectwhat">
<option value="">Select type</option>
<option value="tracking"> Tracking URL + Image</option>
<option value="jsapicode"> Code</option>
</select>
</div>
</div>
<div id="trackingid"></div>
<div id="codeid"></div>
<div style="color:red;padding:5px;">
<?php echo form_error('description'); ?>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="form-field-3" >
Description
</label>
<div class="col-sm-5">
<textarea class="form-control" name="description" placeholder="Description"><?php echo set_value('description');?></textarea>
</div>
</div>
<div style="color:red;padding:5px;">
<?php echo form_error('steps[]'); ?>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="form-field-3" >
Steps<font color="red">*</font>
</label>
<div class="col-sm-5">
<input type="text" class="form-control" name="steps[]" placeholder="steps" value="<?php echo set_value('steps[]'); ?>"> <span style="font:normal 12px agency, arial; color:blue; text-decoration:underline; cursor:pointer;" onclick="addMoreRows(this.form);" > Add More</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="form-field-3" >
</label>
<div class="col-sm-5">
<div id="addedRows">
</div>
</div>
</div>
<!-- <div style="color:red;padding:5px;">
<?php //echo form_error('callback_url'); ?>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="form-field-3" >
CallBack Url
</label>
<div class="col-sm-5">
<input type="text" class="form-control" name="callback_url" placeholder="Callback Url" value="http://182.73.146.18/staging/iRupee/rewarduser.php?offer_id={offer_id}&affiliate_id={affiliate_id}&clickId={aff_sub}" readonly>
</div>
</div>-->
<!-- <div style="color:red;padding:5px;">
<?php //echo form_error('term_condition'); ?>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="form-field-3" >
Term Condition
</label>
<div class="col-sm-5">
<input type="text" class="form-control" name="term_condition" placeholder="Term Condition" value="<?php //echo set_value('term_condition'); ?>">
</div>
</div>-->
<div style="color:red;padding:5px;">
<?php echo form_error('city'); ?>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="form-field-3" >
City
</label>
<div class="col-sm-5">
<input type="text" class="form-control" name="city" placeholder="City" value="<?php echo set_value('city'); ?>">
</div>
</div>
<div style="color:red;padding:5px;">
<?php echo form_error('daily_limit'); ?>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="form-field-3" >
Daily Limit <font color="red">*</font>
</label>
<div class="col-sm-5">
<input type="text" class="form-control" name="daily_limit" placeholder="Daily Limit" value="<?php echo set_value('daily_limit'); ?>">
</div>
</div>
<div style="color:red;padding:5px;">
<?php echo form_error('cashback_amount'); ?>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="form-field-3" >
Cashback Amount <font color="red">*</font>
</label>
<div class="col-sm-5">
<input type="text" class="form-control" name="cashback_amount" placeholder="Cashback Amount" value="<?php echo set_value('cashback_amount'); ?>">
</div>
</div>
<div style="color:red;padding:5px;">
<?php echo form_error('priority'); ?>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="form-field-3" >
Priority
</label>
<div class="col-sm-5">
<select name="priority" class="form-control " >
<option value="">select Priority</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
</div>
<div style="color:red;padding:5px;">
<?php echo form_error('status'); ?>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="form-field-3" >
Offer Status
</label>
<div class="col-sm-5">
<select class="form-control " name='status'>
<option value="">Select Status</option>
<option value="1">Active
</option>
<option value="0">Deactive
</option>
</select>
</div>
</div>
<div style="color:red;padding:5px;">
<?php echo form_error('title_image'); ?>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="form-field-3" >
Select Title Image
</label>
<div class="col-sm-4">
<input type="file" class="filestyle" name="title_image" data-buttonText="Find Image">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="form-field-3" >
Push Notification
</label>
<div class="col-sm-5">
<select class="form-control " name='push_status'>
<option value="1">Yes
</option>
<option value="0" selected>No
</option>
</select>
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary btn-md" size="12px;">
Submit <i class="fa fa-arrow-circle-right"></i>
</button>
<input type="button" value="Go Back" size="8px;" onclick="goBack()" class="btn btn-primary btn-md" style=""/>
</div>
</form>
填充跟踪网址+图片和js_api_code的javascript代码,如下所示
function selectwhat()
{
var selectwhat=$('#selectwhat').val();
if(selectwhat=='tracking')
{
var rowTrackingUrl='<p id="newtracking"><div style="color:red;padding:5px;"><?php echo form_error('tacking_url'); ?>\
</div><div class="form-group"><label class="col-sm-3 control-label" for="form-field-3" >\
Tracking Url<font color="red">*</font></label>\
<div class="col-sm-5">\
<input type="text" class="form-control" id="tacking_urls" name="tacking_url" required placeholder="Tarcking Url" value="<?php echo set_value('tacking_url'); ?>">\
</div></div>\
<div style="color:red;padding:5px;"><?php echo form_error('image'); ?></div>\n\
<div class="form-group"><label class="col-sm-3 control-label" for="form-field-3" >Select Image<font color="red">*</font></label>\n\
<div class="col-sm-4"><input type="file" class="filestyle" name="image" required data-buttonText="Find Image">\n\
</div></div></p>';
jQuery("#trackingid").html(rowTrackingUrl);
}
if(selectwhat=='jsapicode')
{
var rowJsapicode='<p id="newjsapicode"><div style="color:red;padding:5px;">\
<?php echo form_error('js_api_code'); ?>\
</div>\
<div class="form-group">\
<label class="col-sm-3 control-label" for="form-field-3" >\
Js Api Code<font color="red">*</font>\
</label>\
<div class="col-sm-5">\
<textarea type="text" class="form-control" name="js_api_code" required placeholder="Js Api Code" ><?php echo set_value('js_api_code'); ?></textarea>\
</div>\
</div></p>';
jQuery("#trackingid").html(rowJsapicode);
}
}
$(document).on('change','#selectwhat',$(this),selectwhat);
用于跟踪网址的表单验证代码
$this->form_validation->set_rules('tacking_url', 'Tracking Url', 'trim|required|xss_clean|callback_check_tracking_url');
public function check_tracking_url()
{
$this->db->where('content_type_id', $_POST['content_type_id']);
$this->db->where('tacking_url', $_POST['tacking_url']);
$result = $this->db->get('offer_content');
if($result->num_rows() > 0)
{
$this->form_validation->set_message('check_tracking_url','Combination of tracking url and content tye is already exist'); // set your message
return false;
}
else{ return true;}
}
我无法做到这一点我尝试了像这样的jquery验证
function checktrackingurl()
{
var tacking_url= $('#tacking_urls').val();
var content_type_id=$('#super_category_id').val();
if(typeof tacking_url!= "undefined")
{
var url= "<?php echo base_url() ?>checktrackingurl";
var data='tacking_url='+tacking_url+"&content_type_id="+content_type_id;
$.post(url,data,function(msg){
var status=$.trim(msg);
if(status=='alreadyExist')
{
alert("The combination of Tracking Url and Content Type already exist");
return false;
}
else if(status=='notExist'){
alert('hi');
return true;
}
});
}
else{
alert();
}
}
答案 0 :(得分:1)
ArrayList weatherForecast = new ArrayList();
weatherForecast.add("Today - Sunny - 88/63");
weatherForecast.add("Tomorrow - Foggy = 70/46");
weatherForecast.add("Weds - Cloudy - 72/63");
weatherForecast.add("Thurs 6/26 - Rainy - 18/11");
weatherForecast.add("Sat 6/28 - TRAPPED IN WEATHERSTATION - 23/18");
weatherForecast.add("Sun 6/29 - Sunny - 20/7");
chnage在下面给你打电话,根据这个可以帮到你
<div class="col-sm-5">
<select name="selectwhat" class="form-control" id="selectwhat">
<option value="">Select type</option>
<option value="tracking"> Tracking URL + Image</option>
<option value="jsapicode"> Code</option>
</select>
</div>
将此添加到您的jquery
<div class="col-sm-5">
<select name="selectwhat" class="form-control" id="selectwhat">
<option value="" <?php echo set_select('selectwhat', '', true);?>>Select type</option>
<option value="tracking" <?php echo set_select('selectwhat', 'tracking');?> > Tracking URL + Image</option>
<option value="jsapicode" <?php echo set_select('selectwhat', 'jsapicode');?> > Code</option>
</select>
</div>
我认为这会对你有所帮助