-1

I have a form with action method POST. Some Controls in php which are being calculated in jQuery. All the form control values are accessible in next form using POST. But the values I am adding through jQuery are not posting to next form. Please help.

My Form Control Part:

$('#vipcount, #vipprice').keyup(function() {
  var value1 = parseFloat($('#vipcount').val()) || 0;
  var value2 = parseFloat($('#vipprice').val()) || 0;
  var days = parseFloat($('#days').val()) || 0;
  gtotal1 = (value1 * value2) * days;
  gCount1 = value1;
  var value3 = addCommas(gtotal1.toFixed(2)); //(value1 * value2).toFixed(2);
  var value4 = value3 + ' AED';
  //$('#viptotal').val(value4);
  //alert($('#viptotal').val());
  $('#viptotal').text(value4);
  document.getElementsByName("viptotal")[0].value = value4;
  footerFill(gtotal1);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="col-xl-3 col-lg-12">
  <fieldset>
    <h5>VIP Meals Total<small class="text-muted"> </small></h5>
    <div class="form-group">
      <input id="viptotal" class="form-control date-inputmask" type="text" placeholder="0.00 AED" disabled=true name="viptotal" />
    </div>
  </fieldset>
</div>

Part of Code to display this value is like this:

$message .= '<td style="width:35%">' . $_POST['viptotal'] . '</td>';

I don't know where I am wrong.

mplungjan
  • 169,008
  • 28
  • 173
  • 236
Jugnu Khan
  • 63
  • 3
  • 9
  • Where is your `#viptotal` field in your HTML? I notice you're changing the `text()` attribute, but not the actual `val()` of that field, so that's almost certainly part of your problem. – maiorano84 Apr 13 '20 at 06:41
  • 1. Not PHP related. 2: JScript was a MS only scripting language, you mean jQuery. 3. Please click edit, scroll down and click edit above snippet and update the snippet I made you to be a [mcve] - PS: [Browsers do not forward disabled fields](https://stackoverflow.com/questions/1355728/values-of-disabled-inputs-will-not-be-submitted) – mplungjan Apr 13 '20 at 06:48
  • Also please use jQuery when you have it: `$("[name=viptotal]").val(value4) ` or just `$('#viptotal').val(value4);` - input fields do not have .text() – mplungjan Apr 13 '20 at 06:50
  • Dupe of https://stackoverflow.com/questions/1355728/values-of-disabled-inputs-will-not-be-submitted – mplungjan Apr 13 '20 at 06:51
  • 1
    Does this answer your question? [Values of disabled inputs will not be submitted](https://stackoverflow.com/questions/1355728/values-of-disabled-inputs-will-not-be-submitted) – Nick Apr 14 '20 at 11:11

1 Answers1

0

I think that your code have a disabled=" true" for the input field. If the input field is disabled, Request doesn't include the value of the input field. you can add the readonly="readonly" instead of disabled=true. And I can not see the input field with an id called "viptotal".

<input id="viptotal" class="form-control date-inputmask" type="text" placeholder="0.00 AED" readonly="readonly" name="viptotal" />