Copy link to clipboard
Copied
Hi Chaps,
Need a bit of guidence with some PHP code.
I have a Query that estimates a quote ($price_total) for a job.
The estimate ($price_total) is the value of an input (jobquote), and the database is updated once the form is submitted (using a seperate script.php page).
What I need, is to validate the entered value of 'jobquote' against the estimated value of $price_total, just incase a 'custom' price has been agreed with a customer.
If the values are different, then I need an 'admin override' radio button (admin_quote enum('y','n')) to appear.
If someone can help or point me in the right direction, I'd be most grateful.
Cheers
Do you know any jQuery? I think the following might help with what you're trying to do:
...<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Make field editable</title>
<script type="text/javascript" src="js/jquery-1.4.min.js"></script>
<script type="text/javascript">
$(function() {
var jobquote = $('#jobqu
Copy link to clipboard
Copied
Got a bit further:
<input type='text' name='jobquote' value="<?php echo $price_total; ?>"/>
<input type='hidden' name='original_jobquote' value="<?php echo $price_total; ?>"/>
<?php
if ($_POST['original_jobquote'] != $_POST['jobquote'])
{ ?>
<span id="spryradio1">
<input type="radio" name="jobquoteadmin" value="y" id="radio" />Confirm<br />
<span class="radioRequiredMsg">Please confirm Admin Override</span></span>
<?php };
?>
Copy link to clipboard
Copied
It sounds to me as though you need a page that contains a form to get the job quote. Submit that form to a second page that calculates the quote and inserts the result (plus any other information brought over from the first page) into a form where the user continues entering the other details. Then process the complete set of details when the form in the second page is submitted.
Copy link to clipboard
Copied
Hi David,
Thanks for your reply. I think I get what you mean, can I just clarify before I continue. . . .
Copy link to clipboard
Copied
Do you know any jQuery? I think the following might help with what you're trying to do:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Make field editable</title>
<script type="text/javascript" src="js/jquery-1.4.min.js"></script>
<script type="text/javascript">
$(function() {
var jobquote = $('#jobquote');
var value = jobquote.val();
$('#editquote').click(function() {
if (jobquote.attr('readonly')) {
jobquote.removeAttr('readonly');
jobquote.val('');
} else {
jobquote.attr('readonly', 'readonly');
jobquote.val(value);
}
});
});
</script>
</head>
<body>
<?php
if ($_POST) print_r($_POST);
?>
<form id="form1" name="form1" method="post" action="">
<p>
<label for="jobquote">Quote:</label>
<input name="jobquote" type="text" id="jobquote" value="£200" readonly="readonly" />
<input type="checkbox" name="editquote" id="editquote" value="y" />
<label for="editquote">Edit this value</label>
</p>
<p>
<input type="submit" name="send" id="send" value="Submit" />
</p>
</form>
</body>
</html>
For it to work, you need to download jquery-1.4.min.js from jquery.com. If you test it, you'll see that it clears the preset value from the field and allows you to edit it when the checkbox is selected. However, if you deselect the checkbox, it reverts to the original value.
Copy link to clipboard
Copied
Bingo!
I have heard jQuery but haven't had a chance to research it fully.
This looks like something that will deffinately do the trick
Sweet, cheers David
Copy link to clipboard
Copied
Since you haven't experimented with jQuery yet, the script that I created probably looks double-Dutch at the moment. The key to getting it to work in your form lies in the IDs. I gave the checkbox the ID editquote, and the text field the ID jobquote. Either use those IDs in your form, or change all instances of editquote and jobquote in the script to match your IDs.
Copy link to clipboard
Copied
Hi David,
Thanks for the explanation, I managed to work it out though. . . .things must be sticking!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more