How to validate multi step form jquery Php - javascript

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>

Related

Remove HTML Attributes and tags

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

OpenCart Set language through URL

When I select my language from the dropdown flag the opencart translates to the new language and I get directed to the index page.
I want to stay on the current page.
I found an article for this issue but I couldn`t make it work.
Link
This is my current code from catalog/controller/module/language.php
<?php if (count($languages) > 1) { ?>
<!-- Language -->
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="language_form">
<div class="dropdown">
<?php foreach ($languages as $language) { ?>
<?php if ($language['code'] == $code) { ?>
<?php echo $language['name']; ?>
<?php } ?>
<?php } ?>
<ul class="dropdown-menu">
<?php foreach ($languages as $language) { ?>
<li><?php echo $language['name']; ?></li>
<?php } ?>
</ul>
</div>
<input type="hidden" name="code" value="" />
<input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />
</form>
<?php } ?>

How can I change radio buttons to Bootstrap buttons

I am trying to change radio buttons in PHP to buttons from Bootstrap.
(I would also like to get rid of the submit button at the bottom of the page and have these submit the answer.)
This code works but it uses radio buttons:
<div id='javatbd<?php echo $myfname; ?>' class='col-xs-12 form-group answer-item radio-item radio' <?php echo $sDisplayStyle; ?> >
<input
class="radio"
type="radio"
value="<?php echo $code; ?>"
name="<?php echo $name; ?>"
id="answer<?php echo $name.$code; ?>"
<?php echo $checkedState;?>
onclick="if (document.getElementById('answer<?php echo $name; ?>othertext') != null) document.getElementById('answer<?php echo $name; ?>othertext').value='';checkconditions(this.value, this.name, this.type)"
aria-labelledby="label-answer<?php echo $name.$code; ?>"
/>
<label for="answer<?php echo $name.$code; ?>" class="control-label radio-label"></label>
<div class="label-text label-clickable" id="label-answer<?php echo $name.$code; ?>">
<?php echo $answer; ?>
</div>
</div>
.
.
.
<div class="col-xs-6 save-all text-right">
<button type="submit" id="movesubmitbtn" value="movesubmit" name="movesubmit" accesskey="l" class="submit button btn btn-lg btn-primary">Submit</button>
</div>
I've tried this but it does not send the value.
<div id='javatbd<?php echo $myfname; ?>' class='col-xs-12 form-group answer-item radio-item btn' <?php echo $sDisplayStyle; ?> >
<div class="container-fluid">
<input
class="btn btn-primary btn-block"
type="button"
value="<?php echo $code; ?>"
name="<?php echo $name; ?>"
id="answer<?php echo $name.$code; ?>"
<?php echo $checkedState;?>
onclick="if (document.getElementById('answer<?php echo $name; ?>othertext') != null) document.getElementById('answer<?php echo $name; ?>othertext').value='';checkconditions(this.value, this.name, this.type)"
aria-labelledby="label-answer<?php echo $name.$code; ?>"
/>
</div>
</div>
You can use the Bootstrap buttons radio component to make a radio button look like normal button.
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary">
<input type="radio" name="options" id="option1"> Option 1
</label>
<label class="btn btn-primary">
<input type="radio" name="options" id="option2"> Option 2
</label>
<label class="btn btn-primary">
<input type="radio" name="options" id="option3"> Option 3
</label>
</div>
You can see the live example, and other options here - http://www.tutorialrepublic.com/twitter-bootstrap-tutorial/bootstrap-stateful-buttons.php
This worked. Thanks! Now I'll try to remove the O in the middle of the button and remove the Submit button, so clicking on Boss will submit the value.
<div class="btn btn-primary btn-block">
<input
class="radio"
type="radio"
value="<?php echo $code; ?>"
name="<?php echo $name; ?>"
id="answer<?php echo $name.$code; ?>"
<?php echo $checkedState;?>
onclick="if (document.getElementById('answer<?php echo $name; ?>othertext') != null) document.getElementById('answer<?php echo $name; ?>othertext').value='';checkconditions(this.value, this.name, this.type)"
aria-labelledby="label-answer<?php echo $name.$code; ?>"
/>
<label for="answer<?php echo $name.$code; ?>" class="control-label radio-label"></label>
Image of radio / buttons
This worked! Thanks very much! Now I will try to remove the Submit button and make the clicked values submit the value. I'm trying to reduce space on the page.
Bootstrap Radio / buttons. It worked
<div class="btn-block" data-toggle="buttons">
<label class="btn btn-primary btn-block">
<input
class="radio"
type="radio"
value="<?php echo $code; ?>"
name="<?php echo $name; ?>"
id="answer<?php echo $name.$code; ?>"
<?php echo $checkedState;?>
onclick="if (document.getElementById('answer<?php echo $name; ?>othertext') != null) document.getElementById('answer<?php echo $name; ?>othertext').value='';checkconditions(this.value, this.name, this.type)"
aria-labelledby="label-answer<?php echo $name.$code; ?>"
/>
<label for="answer<?php echo $name.$code; ?>" class="control-label radio-label"></label>
<div class="label-text label-clickable" id="label-answer<?php echo $name.$code; ?>">
<?php echo $answer; ?>
</div>
</div>

How to create multiple text area at the time of edit option using PHP and JavSscript

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.

Ignore checkbox that is disable

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 = "";
}
}
}
}

Categories