?
Solved

Help me auto update a field in a webpage based on the value of another field

Posted on 2008-10-15
4
Medium Priority
?
210 Views
Last Modified: 2013-12-13
I need to auto update a total amount due field that is tied to MySQL database through php.
User enters quantity, defaul value is set for price each and total due should update on entering quantity and updating quantity or price each.

I asked a similar question yesterday but realize I did not state my goal clearly.

I currently have code where you must click in the total due field to update it and I want to eliminate this.
Click to update appears in red as default value in total due thanks to an answer I got yesterday but again, I want to eliminate this for a more sophisticated form.

Below is the existing code



<tr>
			<td colspan="2" height="23"><font face="Verdana" style="font-size: 9pt">How many attendees are you paying for?</font></td>
			<td height="23" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #C0C0C0">   	
			<p align="center">   	
			<input id="field1" size="4" name="Attendee_Count" value="<%=Request.Form("Attendee_Count")%>" style="border: 1px solid #FFFFFF; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px; text-align:right; float:right"></font></td>
		</tr>
		</table>
<table border="0" width="100%" cellpadding="0" style="border-collapse: collapse" id="table13" height="26">
		<tr>
			<td width="7%" height="26">&nbsp;</td>
			<td width="51%">&nbsp;</td>
			<td width="28%" height="26">
		<font face="Verdana" style="font-size: 9pt">Cost Each</td>
			<td width="13%" height="26" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #C0C0C0">
		<font face="Arial" size="1">
			<%
Reg_Fee = trim(Request.Form("Reg_Fee"))
If  Reg_Fee = "" then
   Reg_Fee  = "275"
end if
%>
<input id="field2" value="<%=Reg_Fee%>" size="4" name="Reg_Fee" style="border:1px solid #FFFFFF; float: right; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px"></font></td>
		</tr>
		</table>
 
	<table border="0" width="100%" cellpadding="0" style="border-collapse: collapse" id="table14">
		<tr>
			<td width="7%" height="31">&nbsp;</td>
			<td width="51%" height="31">&nbsp;</td>
			<td width="28%" height="31">
			<font face="Verdana" style="font-size: 9pt; font-weight:700">Total Due</td>
<style>
.normalButton{
color: black;
}
.redButton{
color: red;
font-size: 6pt;
}
</style>
			<td height="31" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #C0C0C0">
<%
Total_Due = trim(Request.Form("Total_Due"))
If  Total_Due = "" then
   Total_Due  = "Click to Update"
  end if
%>
 
	<input id="Total_Due" class="redButton" value=<%=Total_Due%> onfocus="document.getElementById('Total_Due').value=document.getElementById('field1').value*document.getElementById('field2').value;document.getElementById('Total_Due').className='normalButton';" size="4" name="Total_Due" style="border: 1px solid #FFFFFF; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px; font-weight:700; float:right" ></font>
	</td>

Open in new window

0
Comment
Question by:Learnin_on_the_fly
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 7

Accepted Solution

by:
bluV11t earned 1500 total points
ID: 22723396
You just do the same in the onBlur events of the two textboxes. I'm assuming you want to do this in JavaScript.
<tr>
                        <td colspan="2" height="23"><font face="Verdana" style="font-size: 9pt">How many attendees are you paying for?</font></td>
                        <td height="23" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #C0C0C0">       
                        <p align="center">      
                        <input id="field1" size="4" name="Attendee_Count" value="<%=Request.Form("Attendee_Count")%>" style="border: 1px solid #FFFFFF; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px; text-align:right; float:right" onBlur="JavaScript: document.getElementById('Total_Due').value=document.getElementById('field1').value*document.getElementById('field2').value;document.getElementById('Total_Due').className='normalButton';"></font></td>
                </tr>
                </table>
<table border="0" width="100%" cellpadding="0" style="border-collapse: collapse" id="table13" height="26">
                <tr>
                        <td width="7%" height="26"> </td>
                        <td width="51%"> </td>
                        <td width="28%" height="26">
                <font face="Verdana" style="font-size: 9pt">Cost Each</td>
                        <td width="13%" height="26" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #C0C0C0">
                <font face="Arial" size="1">
                        <%
Reg_Fee = trim(Request.Form("Reg_Fee"))
If  Reg_Fee = "" then
   Reg_Fee  = "275"
end if
%>
<input id="field2" value="<%=Reg_Fee%>" size="4" name="Reg_Fee" style="border:1px solid #FFFFFF; float: right; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px" onBlur="JavaScript: document.getElementById('Total_Due').value=document.getElementById('field1').value*document.getElementById('field2').value;document.getElementById('Total_Due').className='normalButton';"></font></td>
                </tr>
                </table>
 
        <table border="0" width="100%" cellpadding="0" style="border-collapse: collapse" id="table14">
                <tr>
                        <td width="7%" height="31"> </td>
                        <td width="51%" height="31"> </td>
                        <td width="28%" height="31">
                        <font face="Verdana" style="font-size: 9pt; font-weight:700">Total Due</td>
<style>
.normalButton{
color: black;
}
.redButton{
color: red;
font-size: 6pt;
}
</style>
                        <td height="31" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #C0C0C0">
<%
Total_Due = trim(Request.Form("Total_Due"))
If  Total_Due = "" then
   Total_Due  = "Click to Update"
  end if
%>
 
        <input id="Total_Due" class="redButton" value=<%=Total_Due%> onfocus="document.getElementById('Total_Due').value=document.getElementById('field1').value*document.getElementById('field2').value;document.getElementById('Total_Due').className='normalButton';" size="4" name="Total_Due" style="border: 1px solid #FFFFFF; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px; font-weight:700; float:right" ></font>
        </td>

Open in new window

0
 

Author Comment

by:Learnin_on_the_fly
ID: 22740885
I don't know what this answer means. I was hoping for a recommendation with code.
0
 

Author Comment

by:Learnin_on_the_fly
ID: 22935551
Ok
0
 

Author Comment

by:Learnin_on_the_fly
ID: 22935557
Ok
0

Featured Post

Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question