I have been using this code:
<html>
<head>
<script>
function validatePfin() {
var x1 = document.forms["pfin"]["cash"].value;
var x2 = document.forms["pfin"]["all_assets"].value;
var x3 = document.forms["pfin"]["all_debt"].value;
if (x1 == null || x1 == "") {alert("Please enter Cash Amount.");}
else {
if (x2 == null || x2 == "") {alert("Please enter Non-Cash Assets.");}
else {
if (x3 == null || x3 == "") {alert("Please enter Total Debt.");}
else {
document.getElementById('sub1').value='Processing, please wait ... ';
document.getElementById('sub1').disabled=true;
form.submit();
}}}
return false;
}
</script>
</head>
<body>
<table>
<form method="POST" name="pfin" autocomplete="on" target="vframe" action="p_financials_s.php" enctype="multipart/form-data" onsubmit="return validatePfin()">
<tr><td>
<select name="cash" id="cash">
<option value="<?php echo $row['cash'];?>" selected><?php echo $row['cash'];?></option>
<option value="">Select</option>
<option value="0" >0</option>
<option value="1000" >1000</option>
</select>
<tr><td>
<select name="all_assets" id="all_assets">
<option value="<?php echo $row['all_assets'];?>" selected><?php echo $row['all_assets'];?></option>
<option value="">Select</option>
<option value="0" >0</option>
<option value="1000" >1000</option>
</select>
<tr><td>
<select name="all_debt" id="all_debt">
<option value="<?php echo $row['all_debt'];?>" selected><?php echo $row['all_debt'];?></option>
<option value="">Select</option>
<option value="0" >0</option>
<option value="1000" >1000</option>
</select>
<tr><td>
<input type="submit" id="sub1" class="back1" value="Save And Go To Next Step >">
</table>
</form>
</body></html>
This is a pared down snip from the code. What it does is that upon submission, the form checks to see if the fields have values and if not stops the submission.
What I am trying to figure out is how, using PHP/javascript (or ?), I can 'read' a form field, check to see if it has a value, and make that a variable for a conditional statement, w/o having to submit and post to the DB.
For example, let's say I want the "cash" value to have a value, and if that is true, then I can make that a condition to, let's say, display a link:
<?
$cash1 = form.field.not-yet-sumbitted.cash
if( $cash1 != "") {
echo "http://examplesite.com";
}
?>
I have tried using an onchange event in javascript to somehow bring the "cash" variable into memory, and then once done, somehow have the PHP variable pick it up, but that doesn't fire.