I have here a code that when you clicked the All link it will check all the check boxes and when None it will uncheck all the check boxes.
But I have a PHP conditions that when the $pta_fee == $pta_fee_trans the check box will be disable, but when I clicked the All link, the disable check box appears to be checked.
How can I ignore the disable check box if I checked the All link?
<div class="sub_profile right">
<p class="sub_content_text" style='margin-left: 25px;'>
All | None
MISCELLANEOUS FEES:
</p>
<?php
if($pta_fee == $pta_fee_trans)
{
?>
<p class="sub_content_text" style='margin-left: 30px;'>
<input type='checkbox' value="<?php echo $pta_fee; ?>" disabled>
PTA Fee : ₱ <?php echo $pta_fee; ?></p>
<?php
}
else
{
?>
<p class="sub_content_text" style='margin-left: 30px;'>
<input type='checkbox' name='draw[]' value="<?php echo $pta_fee; ?>" id="required-checkbox1" onClick="CheckIfChecked(this.id)">
PTA Fee : ₱ <?php echo $pta_fee; ?></p>
<?php
}
if($maintenance_fee == $maintenance_fee_trans)
{
?>
<p class="sub_content_text" style='margin-left: 30px;'>
<input type='checkbox' value="<?php echo $maintenance_fee; ?>" disabled>
Maintenance Fee : ₱ <?php echo $maintenance_fee; ?></p>
<?php
}
else
{
?>
<p class="sub_content_text" style='margin-left: 30px;'>
<input type='checkbox' name='draw[]' value="<?php echo $maintenance_fee; ?>" id="required-checkbox2" onClick="CheckIfChecked(this.id)">
Maintenance Fee : ₱ <?php echo $maintenance_fee; ?></p>
<?php
}
if($id_school == $id_school_trans)
{
?>
<p class="sub_content_text" style='margin-left: 30px;'>
<input type='checkbox' value="<?php echo $id_school; ?>" disabled>
School ID : ₱ <?php echo $id_school; ?></p>
<?php
}
else
{
?>
<p class="sub_content_text" style='margin-left: 30px;'>
<input type='checkbox' name='draw[]' value="<?php echo $id_school; ?>" id="required-checkbox3" onClick="CheckIfChecked(this.id)">
School ID : ₱ <?php echo $id_school; ?></p>
<?php
}
if($electricity == $electricity_trans)
{
?>
<p class="sub_content_text" style='margin-left: 30px;'>
<input type='checkbox' value="<?php echo $electricity; ?>" disabled>
Electricity : ₱ <?php echo $electricity; ?></p>
<?php
}
else
{
?>
<p class="sub_content_text" style='margin-left: 30px;'>
<input type='checkbox' name='draw[]' value="<?php echo $electricity; ?>" id="required-checkbox4" onClick="CheckIfChecked(this.id)">
Electricity : ₱ <?php echo $electricity; ?></p>
<?php
}
?>
<div id="sub_profile_cont">
<div class="sub_profile left">
<p class="block_cont left">
<div id = "submit-button-container" style="display:none;">
<input class="action_btn" type="submit" name="submit" id="pay_btn" value="COMPUTE" onClick="setUpdateAction();"/>
</div>
<b style="display: none";><input class="action_btn" type="submit" name="submit" id="pay_btn" value="COMPUTE" onClick="setUpdateAction();"/></b>
</p>
</div>
</div>
</div>
--Here's the javascript code for checking all the check boxes:
<script>
function selectToggle(toggle, form) {
var myForm = document.forms[form];
for( var i=0; i < myForm.length; i++ ) {
if(toggle) {
myForm.elements[i].checked = "checked";
}
else {
myForm.elements[i].checked = "";
}
}
}
Try this:
<script>
function selectToggle(toggle, form) {
var myForm = document.forms[form];
for( var i=0; i < myForm.length; i++ ){
if(myForm.elements[i].disabled != true){
if(toggle){
myForm.elements[i].checked = "checked";
}
else{
myForm.elements[i].checked = "";
}
}
}
}
Related
I am working with multi step form with php, I have array $rec where i am getting all
questions ( from database/dynamic).
I want to validate those fields whose key is mandatory and value is 1 (coming from array($rec)).
I want "next" page/question shouldn't display until I fill first question.
Here is my html code
<form action="<?php echo site_url('Nps/FormAdd'); ?>" method="post">
<?php //echo "<pre>"; print_R($keyslug);?>
<input type="hidden" name="mobile_no" value="<?php echo $keyslug['mobileNo']; ?>">
<input type="hidden" name="contact_mapping_id" value="<?php echo $keyslug['id']; ?>">
<?php $i="1";
$lastElement = end($rec);
$i="1";
foreach($rec as $key => $records)
{
<div class="card" id="<?php echo $records['ques_id']; ?>" >
<?php if($records['type']=="range" )
{
?>
<div class="form-group" style="margin-top: 10px;">
<div class="chart-scale develop-rating">
<?php $j=$records['start_range'];
$max= $records['end_range'];
for($i=$j;$i<=$max; $i++) {
?>
<button id="rating" attr-hide-div="<?php if($i <= $records['min_value']) { echo $records['max_show_ques_id']; } else { echo $records['show_ques_id']; }?>"
attr-show-div="<?php if($i <= $records['min_value']) { echo $records['show_ques_id']; } else { echo $records['max_show_ques_id']; }?>"attr-value="<?php echo $i; ?>" class="btn rating-button-click btn-scale btn-scale-asc-<?php echo $i; ?>">
<?php echo $i; ?>
</button>
<?php } ?>
<input type="hidden" id='ques_<?php echo $records['ques_id']; ?>' class="input-develop all-mandatory-check" attr-required="<?php echo $records['mandatory']; ?>" <?php if($records['IsRatingQuestion']=="1") { ?> name='rangeR_<?php echo $records['ques_id']; ?>' <?php } else { ?> name='ques_<?php echo $records['ques_id']; ?>' <?php } ?> value="">
</div>
</div>
<?php
}
elseif($records['type']=="check_box")
{
?>
<div class="form-group checkboxes">
<label class="form-control-label"><?php echo $records['question']; ?></label>
<div>
<?php
$opt = explode("::", $records['options']);
$result = count($opt);
$i="1";
foreach($opt as $s)
{
?>
<label class="form-container"><?php echo $s; ?>
<input class="all-mandatory-check" type="checkbox" attr-required="<?php echo $records['mandatory']; ?>" id="name" value='<?php echo $s; ?>' name='check_<?php echo $records['ques_id']; ?>[]'>
<span class="checkmark"></span>
</label>
<?php } ?>
</div>
</div>
<?php
}
$key;
if($key!="0"){
?>
<input type="button" name="previous" class="previous action-button" value="Previous" />
<?php } ?>
<?php
$record_last_end = $rec;
$lastElement = array_key_last($record_last_end);
if($key == $lastElement)
{
?>
<input type="submit" name="submit" value="submit" class="next action-button" >
<?php } else { ?>
<input type="button" name="next" id="next1" class="next action-button" value="Next" />
<?php } ?>
</div>
</div>
<?php
//$i++;
} ?>
</form>
Hi i need to remove HTML attributes and tags using php but strip_tag not working give any solutions. Some span attributes come along with the table values. I need to update editable table values in mysql db. Please find the attached Error Image in console log. I am working opencart ecommerce site. Its different kind of php language.
View File
<?php echo $header; ?><?php echo $column_left; ?>
<div id="content">
<div class="page-header">
<div class="container-fluid">
<div class="pull-right"><i class="fa fa-plus"></i>
<button type="submit" form="form-product" formaction="<?php echo $copy; ?>" data-toggle="tooltip" title="<?php echo $button_copy; ?>" class="btn btn-default"><i class="fa fa-copy"></i></button>
<button type="button" data-toggle="tooltip" title="<?php echo $button_delete; ?>" class="btn btn-danger" onclick="confirm('<?php echo $text_confirm; ?>') ? $('#form-product').submit() : false;"><i class="fa fa-trash-o"></i></button>
</div>
<h1><?php echo $heading_title; ?></h1>
<ul class="breadcrumb">
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<li><?php echo $breadcrumb['text']; ?></li>
<?php } ?>
</ul>
</div>
</div>
<div class="container-fluid">
<?php if ($error_warning) { ?>
<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?>
<button type="button" class="close" data-dismiss="alert">×</button>
</div>
<?php } ?>
<?php if ($success) { ?>
<div class="alert alert-success"><i class="fa fa-check-circle"></i> <?php echo $success; ?>
<button type="button" class="close" data-dismiss="alert">×</button>
</div>
<?php } ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-list"></i> <?php echo $text_list; ?></h3>
</div>
<div class="panel-body">
<div class="well">
<div class="row">
<div class="col-sm-4">
<div class="form-group">
<label class="control-label" for="input-name"><?php echo $entry_name; ?></label>
<input type="text" name="filter_name" value="<?php echo $filter_name; ?>" placeholder="<?php echo $entry_name; ?>" id="input-name" class="form-control" />
</div>
<div class="form-group">
<label class="control-label" for="input-model"><?php echo $entry_model; ?></label>
<input type="text" name="filter_model" value="<?php echo $filter_model; ?>" placeholder="<?php echo $entry_model; ?>" id="input-model" class="form-control" />
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label class="control-label" for="input-price"><?php echo $entry_price; ?></label>
<input type="text" name="filter_price" value="<?php echo $filter_price; ?>" placeholder="<?php echo $entry_price; ?>" id="input-price" class="form-control" />
</div>
<div class="form-group">
<label class="control-label" for="input-quantity"><?php echo $entry_quantity; ?></label>
<input type="text" name="filter_quantity" value="<?php echo $filter_quantity; ?>" placeholder="<?php echo $entry_quantity; ?>" id="input-quantity" class="form-control" />
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label class="control-label" for="input-status"><?php echo $entry_status; ?></label>
<select name="filter_status" id="input-status" class="form-control">
<option value="*"></option>
<?php if ($filter_status) { ?>
<option value="1" selected="selected"><?php echo $text_enabled; ?></option>
<?php } else { ?>
<option value="1"><?php echo $text_enabled; ?></option>
<?php } ?>
<?php if (!$filter_status && !is_null($filter_status)) { ?>
<option value="0" selected="selected"><?php echo $text_disabled; ?></option>
<?php } else { ?>
<option value="0"><?php echo $text_disabled; ?></option>
<?php } ?>
</select>
</div>
<div class="form-group">
<label class="control-label" for="input-image"><?php echo $entry_image; ?></label>
<select name="filter_image" id="input-image" class="form-control">
<option value="*"></option>
<?php if ($filter_image) { ?>
<option value="1" selected="selected"><?php echo $text_enabled; ?></option>
<?php } else { ?>
<option value="1"><?php echo $text_enabled; ?></option>
<?php } ?>
<?php if (!$filter_image && !is_null($filter_image)) { ?>
<option value="0" selected="selected"><?php echo $text_disabled; ?></option>
<?php } else { ?>
<option value="0"><?php echo $text_disabled; ?></option>
<?php } ?>
</select>
</div>
<div class="col-sm-12">
<div class="form-group">
<label class="control-label" for="input-date"><?php echo $entry_date; ?></label>
<input type="text" name="filter_date" value="<?php echo $filter_date; ?>" placeholder="<?php echo $entry_date; ?>" id="input-date" class="form-control" />
</div>
<!--<div class="form-group">
<label class="control-label" for="input-quantity"><?php //echo $entry_quantity; ?></label>
<input type="text" name="filter_quantity" value="<?php //echo $filter_quantity; ?>" placeholder="<?php //echo $entry_quantity; ?>" id="input-quantity" class="form-control" />
</div>-->
</div>
<button type="button" id="button-filter" class="btn btn-primary pull-right"><i class="fa fa-filter"></i> <?php echo $button_filter; ?></button>
</div>
</div>
</div>
<form action="<?php echo $delete; ?>" method="post" enctype="multipart/form-data" id="form-product">
<div class="table-responsive">
<table class="table table-bordered table-hover">
<thead>
<tr>
<td style="width: 1px;" class="text-center"><input type="checkbox" onclick="$('input[name*=\'selected\']').prop('checked', this.checked);" /></td>
<td class="text-center"><?php echo $column_image; ?></td>
<td class="text-left"><?php if ($sort == 'pd.name') { ?>
<?php echo $column_name; ?>
<?php } else { ?>
<?php echo $column_name; ?>
<?php } ?></td>
<td class="text-left"><?php if ($sort == 'p.model') { ?>
<?php echo $column_model; ?>
<?php } else { ?>
<?php echo $column_model; ?>
<?php } ?></td>
<td class="text-left"><?php if ($sort == 'p.seo') { ?>
<?php echo $column_seo; ?>
<?php } else { ?>
<?php echo $column_seo; ?>
<?php } ?></td>
<td class="text-left"><?php if ($sort == 'p.date') { ?>
<?php echo $column_date; ?>
<?php } else { ?>
<?php echo $column_date; ?>
<?php } ?></td>
<td class="text-right"><?php if ($sort == 'p.price') { ?>
<?php echo $column_price; ?>
<?php } else { ?>
<?php echo $column_price; ?>
<?php } ?></td>
<td class="text-right"><?php if ($sort == 'p.quantity') { ?>
<?php echo $column_quantity; ?>
<?php } else { ?>
<?php echo $column_quantity; ?>
<?php } ?></td>
<td class="text-left"><?php if ($sort == 'p.status') { ?>
<?php echo $column_status; ?>
<?php } else { ?>
<?php echo $column_status; ?>
<?php } ?></td>
<td class="text-right"><?php echo $column_action; ?></td>
</tr>
</thead>
<tbody>
<?php if ($products) { ?>
<?php foreach ($products as $product) { ?>
<tr id = "<?php $product['product_id'];?>" >
<td class="text-center"><?php if (in_array($product['product_id'], $selected)) { ?>
<input type="checkbox" name="selected[]" value="<?php echo $product['product_id']; ?>" checked="checked" />
<?php } else { ?>
<input type="checkbox" name="selected[]" value="<?php echo $product['product_id']; ?>" />
<?php } ?></td>
<td class="text-center"><?php if ($product['image']) { ?>
<img src="<?php echo $product['image']; ?>" alt="<?php echo $product['name']; ?>" class="img-thumbnail" />
<?php } else { ?>
<span class="img-thumbnail list"><i class="fa fa-camera fa-2x"></i></span>
<?php } ?></td>
<td class="text-left"><?php echo $product['name']; ?></td>
<td class="text-left"><?php echo $product['model']; ?></td>
<td class="text-left"><?php echo $product['keyword']; ?></td>
<td class="text-left"><?php echo $product['date_available']; ?></td>
<td contenteditable="true" onblur = "update(this, 'price','<?php echo $product['product_id']; ?>')" class="text-right"><?php if ($product['special']) { ?>
<span style="text-decoration: line-through;"><?php echo $product['price']; ?></span><br/>
<div class="text-danger"><?php echo $product['special']; ?></div>
<?php } else { ?>
<?php echo $product['price']; ?>
<?php } ?></td>
<td contenteditable="true" onblur = "update(this, 'quantity','<?php echo $product['product_id']; ?>')" class="text-right"><?php if ($product['quantity'] <= 0) { ?>
<span class="label label-warning"><?php echo $product['quantity']; ?></span>
<?php } elseif ($product['quantity'] <= 5) { ?>
<span class="label label-danger"><?php echo $product['quantity']; ?></span>
<?php } else { ?>
<span class="label label-success"><?php echo $product['quantity']; ?></span>
<?php } ?></td>
<td class="text-left"><?php echo $product['status']; ?></td>
<td class="text-left"><i class="fa fa-pencil"></i>
<!--<i class="fa fa-save"></i>--></td>
</tr>
<?php } ?>
<?php } else { ?>
<tr>
<td class="text-center" colspan="8"><?php echo $text_no_results; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</form>
<div class="row">
<div class="col-sm-6 text-left"><?php echo $pagination; ?></div>
<div class="col-sm-6 text-right"><?php echo $results; ?></div>
</div>
</div>
</div>
</div>
<script type="text/javascript"><!--
$('#button-filter').on('click', function() {
var url = 'index.php?route=catalog/product&token=<?php echo $token; ?>';
var filter_name = $('input[name=\'filter_name\']').val();
if (filter_name) {
url += '&filter_name=' + encodeURIComponent(filter_name);
}
var filter_model = $('input[name=\'filter_model\']').val();
if (filter_model) {
url += '&filter_model=' + encodeURIComponent(filter_model);
}
var filter_price = $('input[name=\'filter_price\']').val();
if (filter_price) {
url += '&filter_price=' + encodeURIComponent(filter_price);
}
var filter_quantity = $('input[name=\'filter_quantity\']').val();
if (filter_quantity) {
url += '&filter_quantity=' + encodeURIComponent(filter_quantity);
}
var filter_status = $('select[name=\'filter_status\']').val();
if (filter_status != '*') {
url += '&filter_status=' + encodeURIComponent(filter_status);
}
var filter_image = $('select[name=\'filter_image\']').val();
if (filter_image != '*') {
url += '&filter_image=' + encodeURIComponent(filter_image);
}
var filter_date = $('input[name=\'filter_date\']').val();
if (filter_date) {
url += '&filter_date=' + encodeURIComponent(filter_date);
}
location = url;
});
//--></script>
<script type = "text/javascript">
function update(editableObj, column, product_id)
{
// if(confirm('Are you sure Update this data?'))
// {
//console.log(editableObj, column, product_id);
// return false;
$.ajax({
url: "index.php?route=catalog/product/update&token=<?php echo $token; ?>",
type: "POST",
//dataType: "JSON",
data: "column="+column+"&value="+editableObj.innerHTML+"&product_id="+product_id,
success: function(data) {
// set updated value as old value
$(editableObj).attr('data-old_value',editableObj.innerHTML);
//$(editableObj).css("background","#FDFDFD");
console.log(data);
},
// error: function (data) {
// console.log(data);
// }
});
// }
}
</script>
<script type="text/javascript"><!--
$('input[name=\'filter_name\']').autocomplete({
'source': function(request, response) {
$.ajax({
url: 'index.php?route=catalog/product/autocomplete&token=<?php echo $token; ?>&filter_name=' + encodeURIComponent(request),
dataType: 'json',
success: function(json) {
response($.map(json, function(item) {
return {
label: item['name'],
value: item['product_id']
}
}));
}
});
},
'select': function(item) {
$('input[name=\'filter_name\']').val(item['label']);
}
});
$('input[name=\'filter_model\']').autocomplete({
'source': function(request, response) {
$.ajax({
url: 'index.php?route=catalog/product/autocomplete&token=<?php echo $token; ?>&filter_model=' + encodeURIComponent(request),
dataType: 'json',
success: function(json) {
response($.map(json, function(item) {
return {
label: item['model'],
value: item['product_id']
}
}));
}
});
},
'select': function(item) {
$('input[name=\'filter_model\']').val(item['label']);
}
});
//--></script></div>
<?php echo $footer; ?>
Controller File.
public function update()
{
$this->load->language('catalog/product');
//$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('catalog/product');
// print_r(strip_tags($this->request->post['product_id']));
// print_r($this->request->post['column']);
// print_r(strip_tags(trim($this->request->post['value'])));
// die;
$product_id = strip_tags($this->request->post['product_id']);
$column = $this->request->post['column'];
$editableobj = strip_tags(trim($this->request->post['value']));
$this->model_catalog_product->updateProduct($product_id, $column, $editableobj);
}
Error Report
[52price7897
index.php?route=catalog/product&token=4IEByubsLQVVEvXwKEaL0hytqZose2Wj:1006 52quantity<span class="label label-warning">9878970</span>][1]
strip_tags(html_entity_decode($result['name'],ENT_QUOTES,'UTF-8')) use this one, in $result['name'] give your varaibale name, it will work, you need to also use html_entity_decode function This code is working thanks karthickeyan
I am creating multiple text area using + button and I need to do the same operation when edit option is also there using PHP and JavaScript. Here is my code:
<div style="width:24%; float:left; padding:10px;">No of questions :
<input name="no_of_question" id="ques" class="form-control" placeholder="no of question" value="<?php if($_REQUEST['edit']) { echo $getcustomerobj->no_of_question; } else { echo $_REQUEST['no_of_question']; } ?>" type="text" onkeypress="return isNumberKey(event)">
<div id="err_msg_name" style="font-size:12px; color:#FF0000; text-align: center;"></div>
</div>
<div class="clear"></div>
<div style="padding-bottom:10px;">
Questions : <input type="button" class="btn btn-success btn-sm" name="plus" id="plus" value="+" onClick="addQuestionField();"><input type="button" class="btn btn-danger btn-sm" name="minus" id="minus" value="-" onClick="deleteQuestionField();">
</div>
<div id="container">
<div>
<div style="width:24%; float:left; padding:10px;">
<textarea class="form-control" name="questions0" id="questions" placeholder="Questions" style="background:#FFFFFF;" rows="2"><?php if($_REQUEST['edit']) { echo $getcustomerobj->questions; } else { echo $_REQUEST['questions']; } ?></textarea>
</div>
<div style="float:left;margin-top:37px;">
<?php
$status=array("status"=>'1');
$feeddata=$db->kf_answertype->find($ustatus);
?>
<div style="float:left; margin-right:10px;">
<?php
foreach($feeddata as $v){
?>
<input type="radio" name="answer_type0" id="answer_type0" onClick="selectScale(this.value,'0');" value="<?php echo $v['_id']; ?>"> <?php echo $v['answertype']; ?>
<?php
}
?>
</div>
<div style="float:left; margin-top:-10px;display:none;" id="scaleid0"><select class="form-control" id="nscale0" name="noofscale0">
<option value="">Select Answer Type</option>
<?php
$status=array("status"=>'1');
$feeddata=$db->kf_scale->find($ustatus);
foreach($feeddata as $v){
?>
<option value="<?php echo $v['_id']; ?>" <?php if($getcustomerobj->no_of_scale == $v['_id'] or $_REQUEST['no_of_scale'] == $v['_id']){ print 'selected'; } ?>><?php echo $v['noofscale']; ?></option>
<?php } ?>
</select>
</div>
<div style="clear:both;"></div>
</div>
<div style="clear:both;"></div>
</div>
</div>
</div>
My JavaScript function is given below:
<script>
function addQuestionField(){
var get =$("#ques").val();
if(get==null || get==''){
alert('Please add no of questions');
}else{
var counter = 0;
if (counter > 0){
return;
}else{
counter++;
<?php
$status=array("status"=>'1');
$feeddata=$db->kf_answertype->find($ustatus);
?>
<?php
$status=array("status"=>'1');
$feeddatascale=$db->kf_scale->find($ustatus);
?>
for(var i=1;i<get;i++){
$('#container').append('<div><div style="width:24%; float:left; padding:10px;"> <textarea class="form-control" name="questions'+ i +'" id="questions" placeholder="Questions" style="background:#FFFFFF;" rows="2"><?php if($_REQUEST['edit']) { echo $getcustomerobj->questions; } else { echo $_REQUEST['questions']; } ?></textarea></div><div style="float:left;margin-top:37px;"><div style="float:left; margin-right:10px;"><?php foreach($feeddata as $v){?> <input type="radio" name="answer_type'+i+'" id="answer_type0" onClick="selectScale(this.value,'+i+');" value="<?php echo $v['_id']; ?>"> <?php echo $v['answertype']; ?> <?php }?></div><div style="float:left; margin-top:-10px;display:none;" id="scaleid'+i+'"><select class="form-control" id="nscale'+i+'" name="noofscale'+i+'"><option value="">Select Answer Type</option><?php foreach($feeddatascale as $v){ ?><option value="<?php echo $v['_id']; ?>" <?php if($getcustomerobj->no_of_scale == $v['_id'] or $_REQUEST['no_of_scale'] == $v['_id']){ print 'selected'; } ?>><?php echo $v['noofscale']; ?></option><?php } ?></select></div><div style="clear:both;"></div></div><div style="clear:both;"></div></div>');
}
}
}
}
function deleteQuestionField(){
var get =$("#ques").val();
var textareas = $('#container textarea');
if (textareas.length !== 0) {
textareas.last().remove();
$('#ques').val(textareas.length - 1);
}
}
</script>
Here I can create the multiple text-area,radio button using + button which depends on no of questions field value. Here I need to do the same thing when the following condition is true.
if($id!='' && $_REQUEST['edit']==1){
}
at the time of page reload if the above condition is true then no need to click on + button, the multiple field should also created.
I need one help.I need to trigger one click event which has applied to a button but it can not happen like that i am explaining my code below.
<div style="width:24%; float:left; padding:10px;">No of questions :
<input name="no_of_question" id="ques" class="form-control" placeholder="no of question" value="<?php if($_REQUEST['edit']) { echo $getcustomerobj->no_of_question; } else { echo $_REQUEST['no_of_question']; } ?>" type="text" onkeypress="return isNumberKey(event)">
<?php
if($id!='' && $_REQUEST['edit']==1){
echo " <script type=\"text/javascript\"> $('#plus').click(\"".$id."\") </script> ";
}
?>
<div id="err_msg_name" style="font-size:12px; color:#FF0000; text-align: center;"></div>
</div>
<div class="clear"></div>
<div style="padding-bottom:10px;">
Questions : <input type="button" class="btn btn-success btn-sm" name="plus" id="plus" value="+" onClick="addQuestionField();"><input type="button" class="btn btn-danger btn-sm" name="minus" id="minus" value="-" onClick="deleteQuestionField();">
</div>
my java script function is given below.
<script>
function addQuestionField(id){
console.log('ids',id);
var get =$("#ques").val();
if(get==null || get==''){
alert('Please add no of questions');
}else{
var counter = 0;
if (counter > 0){
return;
}else{
counter++;
<?php
$status=array("status"=>'1');
$feeddata=$db->kf_answertype->find($ustatus);
?>
<?php
$status=array("status"=>'1');
$feeddatascale=$db->kf_scale->find($ustatus);
?>
for(var i=1;i<get;i++){
$('#container').append('<div><div style="width:24%; float:left; padding:10px;"> <textarea class="form-control" name="questions'+ i +'" id="questions" placeholder="Questions" style="background:#FFFFFF;" rows="2"><?php if($_REQUEST['edit']) { echo $getcustomerobj->questions; } else { echo $_REQUEST['questions']; } ?></textarea></div><div style="float:left;margin-top:37px;"><div style="float:left; margin-right:10px;"><?php foreach($feeddata as $v){?> <input type="radio" name="answer_type'+i+'" id="answer_type0" onClick="selectScale(this.value,'+i+');" value="<?php echo $v['_id']; ?>"> <?php echo $v['answertype']; ?> <?php }?></div><div style="float:left; margin-top:-10px;display:none;" id="scaleid'+i+'"><select class="form-control" id="nscale'+i+'" name="noofscale'+i+'"><option value="">Select Answer Type</option><?php foreach($feeddatascale as $v){ ?><option value="<?php echo $v['_id']; ?>" <?php if($getcustomerobj->no_of_scale == $v['_id'] or $_REQUEST['no_of_scale'] == $v['_id']){ print 'selected'; } ?>><?php echo $v['noofscale']; ?></option><?php } ?></select></div><div style="clear:both;"></div></div><div style="clear:both;"></div></div>');
}
}
}
}
</script>
I need when that if condition will true the below function should called but its not happening like that.Please help me.
we have a marketplace site. each seller/vendor have their own account.
we are displaying list of sellers products , qty, sku...etc in their account.
http://prntscr.com/8vgul0
we are using this code to display those information :
<?php
$isPartner= Mage::getModel('marketplace/userprofile')->isPartner();
$helper= Mage::helper('marketplace');
if($isPartner==1){
?>
<script type="text/javascript">
if (typeof jQuery == 'undefined'){
document.write(unescape("%3Cscript src='//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<div class="page-title">
<h1 style="float:left;"><?php echo $helper->__('My Product List') ?></h1>
</div>
<div class="wk_mp_design">
<div class="block block-account">
<div class="block-title">
<strong><span><h4><?php echo $helper->__('Product List') ?></h4></span></strong>
</div>
</div>
<div class="fieldset wk_mp_fieldset">
<div class="grid">
<div class="hor-scroll">
<form action="<?php echo Mage::helper('core/url')->getCurrentUrl();?>" method="post">
<table cellspacing="0" class="border wk_mp_list_table">
<thead>
<tr id="wk_mp_tr_heading">
<th><span><?php echo $helper->__('Product Name') ?></span></th>
<th><span><?php echo $helper->__('Date') ?></span></th>
<th><span><?php echo $helper->__('Product Status') ?></span></th>
<th><span> </span></th>
</tr>
</thead>
<tbody class="wk_mp_body">
<tr>
<td>
<input type="text" class="input-text" name="s" placeholder='<?php echo $helper->__('Search by product name') ?>' value="<?php echo $this->getRequest()->getParam('s')?>"/>
</td>
<td>
<span class="wk_mp_td_span">
<?php echo $helper->__('From: ') ?>
<input name="from_date" id="special_from_date" class="input-text" value="<?php echo $this->getRequest()->getParam('from_date')?>" />
</span>
<span class="wk_mp_td_span">
<?php echo $helper->__('To: ') ?>
<input name="to_date" id="special_to_date" class="input-text" value="<?php echo $this->getRequest()->getParam('to_date')?>" />
</span>
</td>
<td>
<select name="prostatus" class="input-text">
<option value=""><?php echo $helper->__('All') ?></option>
<option value="1" <?php if($this->getRequest()->getParam('prostatus') == 1) echo 'selected="selected"'?>>
<?php echo $helper->__('Approved') ?>
</option>
<option value="2" <?php if($this->getRequest()->getParam('prostatus') == 2) echo 'selected="selected"'?>>
<?php echo $helper->__('Unapproved') ?>
</option>
</select>
</td>
<td>
<button class="button" title="Save" type="submit">
<span><span><span><?php echo $helper->__('Submit') ?></span></span></span>
</button>
</td>
</tr>
</tbody>
</table>
</form>
<?php
if(count($this->getCollection())==0){ ?>
<div class="fieldset wk_mp_fieldset">
<div class="wk_emptymsg">
<?php echo $helper->__('No Product Available') ?>
</div>
</div>
<?php
} else{ ?>
<form action="<?php echo $this->getUrl('marketplace/marketplaceaccount/massdeletesellerpro') ?>" method="post" id="formmassdelete" name="formmassdelete">
<input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" />
<button class="button" title="<?php echo $helper->__('Delete Products') ?>" type="submit" style="float: left;padding: 5px 5px 5px 0;" id="mass_delete_butn">
<span><span><?php echo $helper->__('Delete Products') ?></span></span>
</button>
<table cellspacing="0" class="border wk_mp_list_table wk_mp_list_container_table">
<thead>
<tr class="wk_content">
<th class="wk_check_first_td">
<span>
<input type="checkbox" name="mpselecctall" value="all" id="mpselecctall"/>
</span>
</th>
<th class="wk_first_td">
<span class="label name">
<?php echo $helper->__('Product')?>
</span>
</th>
<th class="wk_first_td">
<span class="label name">
<?php echo $helper->__('sku')?>
</span>
</th>
<th>
<span class="label pro_status">
<?php echo $helper->__('Status')?>
</span>
</th>
<!--
<th>
<span class="label qty">
<?php echo $helper->__('Qty. Confirmed')?>
</span>
</th>
<th>
<span class="label qty">
<?php echo $helper->__('Qty. Pending')?>
</span>
</th>
<th>
<span class="label qty">
<?php echo $helper->__('Qty. Sold')?>
</span>
</th>
-->
<th>
<span class="label">
<?php echo $helper->__('Qty')?>
</span>
</th>
<th>
<span class="label">
<?php echo $helper->__('Earn Amount')?>
</span>
</th>
<th>
<span class="label">
<?php echo $helper->__('Action')?>
</span>
</th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach($this->getCollection() as $products){
$i++;
$productMediaConfig = Mage::getModel('catalog/product_media_config');
$salesdetail=Mage::getModel('marketplace/saleslist')->getSalesdetail($products->getEntityId());
?>
<tr class="wk_row_view <?php echo $class = ($i == count($this->getCollection()))? 'wk_last_tr':''?>">
<td class="wk_check_first_td">
<span>
<input type="checkbox" name="product_mass_delete[]" class="mpcheckbox" value="<?php echo $products->getEntityId(); ?>"/>
</span>
</td>
<td class="wk_first_td">
<input type="hidden" class="hidden_id" value="<?php echo $products->getEntityId(); ?>" />
<div class="label name" title="<?php echo $products->getName(); ?>">
<div class="wk_pro_divide1">
<img src="<?php echo Mage::helper('catalog/image')->init($products,'thumbnail');?>" class="image" />
</div>
<div class="wk_pro_divide2">
<div style="width:100%;">
<a href="<?php echo $this->getUrl($products->getUrlPath())?>" target="blank">
<?php echo $products->getName();?>
</a>
</div>
<div style="width:100%;float:left;">
<?php echo Mage::helper('core')->currency($products->getPrice(), true, false);?>
</div>
</div>
</div>
</td>
<td>
<?php echo $sku = Mage::getModel('catalog/product')->load($products->getId())->getSku();?>
</td>
<?php
if($products->getStatus()==2) { ?>
<td>
<span class="label pro_status">
<?php echo $helper->__('Pending')?>
</span>
</td>
<td>
<span class="label qty">
<?php echo $helper->__('Pending')?>
</span>
</td>
<td>
<span class="label qty">
<?php echo $helper->__('Pending')?>
</span>
</td>
<td>
<span class="label qty">
<?php echo $helper->__('Pending')?>
</span>
</td>
<td>
<span class="label qty">
<?php echo $helper->__('Pending')?>
</span>
</td>
<?php }
else{
$id=$products->getId();
$productsolddetail=Mage::getModel('marketplace/saleslist')->getProductSalesDetailById($id);
$qtycom=0;
$com=0;
foreach($productsolddetail as $key){
$qtycom+=$key['magequantity'];
$com+=$key['actualparterprocost'];
} ?>
<td>
<span class="label pro_status">
<?php echo $helper->__('Approved')?>
</span>
</td>
<!-- edit qty -->
<td>
<?php echo (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($products)->getQty(); ?>
<span class="label wk_action">
<img src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>" data-type="<?php echo $products->getTypeId(); ?>" alt="<?php echo $helper->__('Edit')?>" title="<?php echo $helper->__('Edit')?>" class="mp_edit"/>
</span>
</td>
<!-- edit qty end -->
<!--
<td>
<span class="label qty">
<?php echo $salesdetail['quantitysoldconfirmed']; ?>
</span>
</td>
<td>
<span class="label qty">
<?php echo $salesdetail['quantitysoldpending']; ?>
</span>
</td>
<td>
<span class="label qty">
<?php echo $salesdetail['quantitysold']; ?>
</span>
</td>
-->
<td>
<span class="label price">
<?php echo Mage::helper('core')->currency($salesdetail['amountearned'], true, false); ?>
</span>
</td>
<?php
}?>
<td>
<span class="label wk_action">
<img src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>" data-type="<?php echo $products->getTypeId(); ?>" alt="<?php echo $helper->__('Edit')?>" title="<?php echo $helper->__('Edit')?>" class="mp_edit"/>
<img src="<?php echo $this->getSkinUrl('marketplace/images/icon-trash.png'); ?>" alt="<?php echo $helper->__('Delete')?>" title="<?php echo $helper->__('Delete')?>" class="mp_delete"/>
</span>
</td>
</tr>
<?php
}?>
</tbody>
</table>
</form>
<?php
}?>
</div>
</div>
<?php echo $this->getPagerHtml(); ?>
</div>
<div class="buttons-set">
<p class="back-link">
« <?php echo $helper->__('Back') ?>
</p>
</div>
</div>
<script>
var $wk_jq=jQuery.noConflict();
var newCustomerProductForm1 = new VarienForm('formmassdelete', true);
(function($wk_jq){
$wk_jq( "#special_from_date" ).datepicker({dateFormat: "yy-mm-dd"});
$wk_jq( "#special_to_date" ).datepicker({dateFormat: "yy-mm-dd"});
$wk_jq('body').delegate('.mp_edit','click',function(){
var id=$wk_jq(this).parents('.wk_row_view').find('.hidden_id').val();
var dicision=confirm('<?php echo $helper->__(" Are you sure you want to edit this product ? ")?>');
if(dicision==true){
var $type_id=$wk_jq(this).attr('data-type');
if($type_id=='simple')
window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/editapprovedsimple/') ?>".concat("id/",id);
if($type_id=='downloadable')
window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/editapproveddownloadable/') ?>".concat("id/",id);
if($type_id=='virtual')
window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/editapprovedvirtual/') ?>".concat("id/",id);
if($type_id=='configurable')
window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/editapprovedconfigurable/') ?>".concat("id/",id);
if($type_id=='grouped')
window.location = "<?php echo $this->getUrl('mpgroupproduct/index/editapprovedgrouped/') ?>".concat("id/",id);
<?php
//echo $this->getChildHtml('mpgrouped_productslist');
// echo $this->getChildHtml('mpbundle_productslist');
?>
if($type_id=='bundle')
window.location = "<?php echo $this->getUrl('mpbundleproduct/index/editbundle/') ?>".concat("id/",id);
}
});
$wk_jq('#mass_delete_butn').click(function(e){
var flag =0;
$wk_jq('.mpcheckbox').each(function(){
if (this.checked == true){
flag =1;
}
});
if (flag == 0){
alert("<?php echo $helper->__(' No Checkbox is checked ') ?>");
return false;
}
else{
var dicisionapp=confirm('<?php echo $helper->__(" Are you sure you want to delete these product ? ")?>');
if(dicisionapp==true){
$wk_jq('#form-customer-product-new').submit();
}else{
return false;
}
}
});
$wk_jq('#mpselecctall').click(function(event) {
if(this.checked) {
$wk_jq('.mpcheckbox').each(function() {
this.checked = true;
});
}else{
$wk_jq('.mpcheckbox').each(function() {
this.checked = false;
});
}
});
$wk_jq('.mp_delete').click(function(){
var id=$wk_jq(this).parents('.wk_row_view').find('.hidden_id').val();
var dicisionapp=confirm('<?php echo $helper->__(" Are you sure you want to delete this product ? ")?>');
if(dicisionapp==true)
window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/delete/') ?>".concat("id/",id);
});
})($wk_jq);
</script>
<?php
}else{
echo "<h2 class='wk_new_msg'>".$helper->__("To BECOME SELLER PLEASE CONTACT TO ADMIN.")."</h2>";
}?>
we have a edit button next to "Qty", if we click on that edit button, its redirecting to another page and than seller edit the information and save it.
we are using following code to edit :
<span class="label wk_action">
<img src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>" data-type="<?php echo $products->getTypeId(); ?>" alt="<?php echo $helper->__('Edit')?>" title="<?php echo $helper->__('Edit')?>" class="mp_edit"/>
</span>
what we need is if we click on "edit" button, then it should display text field as like in the image and update and cancel button below.
Please refer below URL for admin grid:
http://www.atwix.com/magento/inline-editing-in-magento-backend-grids/
I'm not sure but this may help you. Try below for front-end :
Step 1 : Make onclick event on your edit image and call javascript function
eg : onclick="updateField(this, '. $product_id .'); return false";
Step 2 : Create javascript function which you have define in onclick of image.
<?php $url='Mage::getUrl('module_name/index/updateField/');' ?>
<script type="text/javascript">
function updateField(image, product_id)
{
new Ajax.Request('<?php echo $url ?>', {
method: 'post',
parameters: { id: fieldId, field: $(button).previous('input').getValue() }
});
}
</script>
Step: 3 Make function in your controller that you have define in java script ajax url.
public function updateFieldAction()
{
$fieldId = (int) $this->getRequest()->getParam('id');
$field = $this->getRequest()->getParam('field');
if ($fieldId) {
$model = Mage::getModel('modulename/model')->load($fieldId);
$model->setField($field);
$model->save();
}
}