After a bit of help and learning, I have managed to change a target via JScript, but I can't seem to figure out how to make a variable or make it do a calculation.
My code so far is (these are three Form Boxes + a Submit Button):
NUMBER
<input name="contact_build"
type="text"
id="contact_build"
value="<?php echo $row_contact['contact_build']; ?>" />
TYPE
<select id="contact_type"
name="contact_type"
onchange="targ.value=this.value" />
<?php
$specresult = mysql_query("SELECT * FROM `types` ORDER BY type_value");
while ($specrow = mysql_fetch_array($specresult)) {
echo '<option value="' . $specrow['type_name'] . '">' . $specrow['type_name'] . '</option>';
}
?>
</select>
VALUE
<input name="contact_value" id="targ" value="<?php
$var1 = $row_contact['contact_build'];
$var2 = $row_value['type_value'];
$total = round($var2 * $var1);
echo "" . $total . "";
?>" />
<input type="submit" name="Submit2" value="Update" />
What I want to do is make "TARG"
the "$VAR2"
variable, so that it can work out the VALUE calculation then echo (or what ever command is required) the answer in the VALUE box, as soon as the user changes the option in the TYPE box. Hope this makes sense.
At the moment I have managed to get it to show the "TYPE"
value in the "VALUE"
box. It ignores any "echo" command above.
Am I looking at this incorrectly and it should be done another way?
PS: I know it's MYSQL; I am working on learning PDO as we speak to change it over. :-) But for the moment, I just want to figure this out using the language that I have basic knowledge of.