close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Automatically calculating, and displaying, somone's BMI in a form field using data the user has submitted in seperate height and weight form fields

Thread began 2/08/2019 5:27 pm by Nathon Jones Web Design | Last modified 2/11/2019 12:53 pm by Ray Borduin | 41 views | 2 replies |

Nathon Jones Web Design

Automatically calculating, and displaying, somone's BMI in a form field using data the user has submitted in seperate height and weight form fields

However, it's made more complicated because I am giving the user the option to choose:
1) Height as either CM or Feet & Inches
2) Weight as either Kg or Stones & Lbs

It's also made complicated by the fact that there is WebAssist Validation running on the form AND that this is an UPDATE form. Here's where I've got to so far, on this specific section:

<div class="form-group row">
<label for="Height" class="col-sm-4 col-form-label">Height</label>
<div class="col-sm-8">
<div class="row">
<div id="FeetInches" class="col HeightOptions">
<div class="input-group mb-2">
<input type="number" class="input Height form-control" name="HeightFt" id="HeightFt" placeholder="Feet" value="<?php echo(isset($_GET['v2'])?ValidatedField("healthscreeningform_476","HeightFt"):$rsEDITFORM->getColumnVal("HeightFt")) ?>">

<div class="input-group-append">
<div class="input-group-text">ft</div>
</div>

<input type="number" class="input Height form-control" name="HeightIn" id="HeightIn" placeholder="Inches" value="<?php echo(isset($_GET['v2'])?ValidatedField("healthscreeningform_476","HeightIn"):$rsEDITFORM->getColumnVal("HeightIn")) ?>">

<div class="input-group-append">
<div class="input-group-text">in</div>
</div>
</div>
</div>

<div id="Centimetres" class="col HeightOptions">
<div class="input-group mb-2">
<input type="number" class="input Height form-control" name="HeightCm" id="HeightCm" placeholder="Centimetres" value="<?php echo(isset($_GET['v2'])?ValidatedField("healthscreeningform_476","HeightCm"):$rsEDITFORM->getColumnVal("HeightCm")) ?>">

<div class="input-group-append">
<div class="input-group-text">cm</div>
</div>
</div>
</div>


<div class="col">
<div class="button dropdownHeight">
<select name="HeightSelector" id="HeightSelector" class="form-control">
<option value="" <?php if (!(strcmp("", (isset($_GET['v2'])?ValidatedField("healthscreeningform_476","HeightSelector"):$rsEDITFORM->getColumnVal("HeightSelector"))))) {echo "selected=\"selected\"";} ?>>Please Select</option>
<option value="FeetInches" <?php if (!(strcmp("FeetInches", (isset($_GET['v2'])?ValidatedField("healthscreeningform_476","HeightSelector"):$rsEDITFORM->getColumnVal("HeightSelector"))))) {echo "selected=\"selected\"";} ?>>Feet &amp; Inches</option>
<option value="Centimetres" <?php if (!(strcmp("Centimetres", (isset($_GET['v2'])?ValidatedField("healthscreeningform_476","HeightSelector"):$rsEDITFORM->getColumnVal("HeightSelector"))))) {echo "selected=\"selected\"";} ?>>Centimetres</option>
</select>
</div>
</div>
</div><!-- /row -->
</div>
</div>

<div class="form-group row">
<label for="Weight" class="col-sm-4 col-form-label">Weight</label>
<div class="col-sm-8">
<div class="row">
<div id="Kg" class="col WeightOptions">
<div class="input-group mb-2">
<input type="number" class="input Weight form-control" name="WeightKg" id="WeightKg" placeholder="Kilograms" value="<?php echo(isset($_GET['v2'])?ValidatedField("healthscreeningform_476","WeightKg"):$rsEDITFORM->getColumnVal("WeightKg")) ?>">

<div class="input-group-append">
<div class="input-group-text">kg</div>
</div>
</div>
</div>

<div id="Lbs" class="col WeightOptions">
<div class="input-group mb-2">
<input type="number" class="input Weight form-control" name="WeightLbs" id="WeightLbs" placeholder="Pounds" value="<?php echo(isset($_GET['v2'])?ValidatedField("healthscreeningform_476","WeightLbs"):$rsEDITFORM->getColumnVal("WeightLbs")) ?>">

<div class="input-group-append">
<div class="input-group-text">lbs</div>
</div>
</div>
</div>

<div class="col">
<div class="button dropdownWeight">
<select name="WeightSelector" id="WeightSelector" class="form-control">
<option value="" <?php if (!(strcmp("", (isset($_GET['v2'])?ValidatedField("healthscreeningform_476","WeightSelector"):$rsEDITFORM->getColumnVal("WeightSelector"))))) {echo "selected=\"selected\"";} ?>>Please Select</option>
<option value="Kg" <?php if (!(strcmp("Kg", (isset($_GET['v2'])?ValidatedField("healthscreeningform_476","WeightSelector"):$rsEDITFORM->getColumnVal("WeightSelector"))))) {echo "selected=\"selected\"";} ?>>Kilograms</option>
<option value="Lbs" <?php if (!(strcmp("Lbs", (isset($_GET['v2'])?ValidatedField("healthscreeningform_476","WeightSelector"):$rsEDITFORM->getColumnVal("WeightSelector"))))) {echo "selected=\"selected\"";} ?>>Pounds</option>
</select>
</div>
</div>
</div>
</div>
</div>

<div class="form-group row">
<label for="MCbmi" class="col-sm-4 col-form-label">BMI</label>
<div class="col-sm-8">
<input type="number" class="form-control" name="MCbmi" id="MCbmi" placeholder="BMI" value="<?php echo(isset($_GET['v2'])?ValidatedField("healthscreeningform_476","MCbmi"):$rsEDITFORM->getColumnVal("MCbmi")) ?>" required>
</div>
</div>



I had also started working on some JS, but because the customer has two options for both height and weight, I became completely confused by it.

<script>
$(function() {
$('#HeightSelector').change(function(){
$('.HeightOptions').hide();
$('#' + $(this).val()).show();
});
});
</script>

<script>
$(function() {
$('#WeightSelector').change(function(){
$('.WeightOptions').hide();
$('#' + $(this).val()).show();
});
});
</script>

<script>
$(document).ready(function(){
$(".input").keyup(function(){
var val1 = +$(".HeightFt").val();
var val2 = +$(".HeightIn").val();
var val3 = +$(".Weight").val();
$("#BMI").val(((val1 + "." + val2)*(val1 + "." + val2))/val3);
});
});
</script>



I also attach the page in question. The above code starts at line 995.
Could you help me with this Ray? Happy to arrange a Premium Support session with you.

Thank you.
NJ

Sign in to reply to this post

Ray BorduinWebAssist

This should be easy to get working in a premier support ticket. I have time monday next week... just message me in Skype and we can schedule it.

Sign in to reply to this post

Nathon Jones Web Design

I'll message you on Monday.

I'm about to try to integrate PayPal Express Checkout on this site too and will, no doubt, run into problems with it, in particular I need to store what's sent back from PayPal into database, and update the order status as paid, and I've no idea how to do any of that.

Speak to you next week. Thank you.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...