将输入值存储为变量以用于等式[关闭]

I'm putting data from a mysql db and place it within a hidden input field. From there I want to store the value of the input field as a javascript variable so that I may run an equation on it.

The following is an example the code:

<input type="text" name="hiddenValue" value="<?php include('select.php'); ?>">

var inputValue = $("#hiddenValue").val();

var startValue = ((inputValue - totalCost) / totalCost ) * 100;

set an id attribute to your input :

<input type="text" id="hiddenValue" name="hiddenValue" value="<?php include('select.php'); ?>">

$("#hiddenValue").val(); selected the element that id=hiddenValue

$("input[name='hiddenValue']").val();

You are using the id selector # and in this case, it does not exist.