We help IT Professionals succeed at work.
Get Started

Change value of textbox based on dropdown select

538 Views
Last Modified: 2012-05-09
I want to change the value of a text input box.  Couple things, this is coded in a custom CRM, so not all traditional solutions may work  or may require some fancy footwork to get it to work.  

Right now, the page properly show / hides information according to the drop down.  Now, I need to change the default value of several of the text boxes based on the selection from that dropdown as well.  Those text boxes also cannot be editable by the user.

In the beginning of the code, I am setting default values to the textboxes.
<tr>
							<td class='borderMedium pad border bgLightest' colspan=5>Contract Type:<%GetSelection "dbContractType2", Array("--Select--", "Retail", "MOTO", "Wireless", "Auth.net", "Check Guarantee", "Check 21"), Array("--Select--", "Retail", "MOTO", "Wireless", "Auth.net", "Check Guarantee", "Check 21"), dLocal("dbContractType2"), 0, 1%></td>
						<tr>
						<tr>
							<td class='' colspan=5><img src='image/empty.gif' width=100% height=5></td>
						</tr>
						<tr><td class='border pad borderMedium' colspan=5><table width='100%' height='100%'>
						<%  Write "<script language=javascript>Property('dbContractType2', 'onchange', 'showRateSchedule', 1);"
						
						    Write "function showRateSchedule(){"
							
							Write "document.getElementById('DiscountRate').className = (this.value=='Retail' || this.value=='MOTO' || this.value=='Wireless' || this.value=='Check Guarantee' || this.value=='Check 21' || this.value=='Auth.net')? 'show':'hide';"
							Write "document.getElementById('TransFee').className = (this.value=='Retail' || this.value=='MOTO' || this.value=='Wireless' || this.value=='Check Guarantee' || this.value=='Check 21' || this.value=='Auth.net')? 'show':'hide';"
							Write "document.getElementById('DebitTrans').className = (this.value=='Retail' || this.value=='MOTO' || this.value=='Wireless' || this.value=='Check Guarantee' || this.value=='Check 21' || this.value=='Auth.net')? 'show':'hide';"
							Write "document.getElementById('Statement').className = (this.value=='Retail' || this.value=='MOTO' || this.value=='Wireless' || this.value=='Check Guarantee' || this.value=='Check 21' || this.value=='Auth.net')? 'show':'hide';"
							Write "document.getElementById('Minimum').className = (this.value=='Retail' || this.value=='MOTO' || this.value=='Wireless' || this.value=='Check Guarantee' || this.value=='Check 21' || this.value=='Auth.net')? 'show':'hide';"
							Write "document.getElementById('Membership').className = (this.value=='Retail' || this.value=='MOTO' || this.value=='Wireless' || this.value=='Check Guarantee' || this.value=='Check 21' || this.value=='Auth.net')? 'show':'hide';"							
							Write "document.getElementById('AVS').className = (this.value=='Retail' || this.value=='MOTO' || this.value=='Wireless' || this.value=='Check Guarantee' || this.value=='Check 21' || this.value=='Auth.net')? 'show':'hide';"
							
							Write "document.getElementById('CheckRate').className = (this.value=='Check Guarantee')? 'show':'hide';"
							Write "document.getElementById('CheckTrans').className = (this.value=='Check Guarantee')? 'show':'hide';"
							Write "document.getElementById('CheckStatement').className = (this.value=='Check Guarantee')? 'show':'hide';"
							Write "document.getElementById('CheckMin').className = (this.value=='Check Guarantee')? 'show':'hide';"	
							
							Write "document.getElementById('AuthSetup').className = (this.value=='Auth.net')? 'show':'hide';"				
							Write "document.getElementById('AuthMonthly').className = (this.value=='Auth.net')? 'show':'hide';"					
							Write "document.getElementById('AuthTrans').className = (this.value=='Auth.net')? 'show':'hide';"				
							
							Write "document.getElementById('WirelessSetup').className = (this.value=='Wireless')? 'show':'hide';"				
							Write "document.getElementById('WirelessMonthly').className = (this.value=='Wireless')? 'show':'hide';"					
							Write "document.getElementById('WirelessTrans').className = (this.value=='Wireless')? 'show':'hide';"						
							
							Write "document.getElementById('Check21NP').className = (this.value=='Check 21')? 'show':'hide';"				
							Write "document.getElementById('Check21F2F').className = (this.value=='Check 21')? 'show':'hide';"					
							Write "document.getElementById('Check21Trans').className = (this.value=='Check 21')? 'show':'hide';"				
							Write "document.getElementById('Check21Payroll').className = (this.value=='Check 21')? 'show':'hide';"				
							
							Write "document.getElementById('Header').className = (this.value=='Retail' || this.value=='MOTO' || this.value=='Wireless' || this.value=='Check Guarantee' || this.value=='Check 21')? 'show':'hide';"	
							
							Write "}"
							Write "</script>"
							%>
							
							
						<tr>
							<td class='bold borderBottom' id='Header'></td>
						</tr>
						<tr class='Red'>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Retail" Or dLocal("dbContractType2") =  "Wireless" Or dLocal("dbContractType2") =  "Check Guarantee" Or dLocal("dbContractType2") =  "Check 21", "show", "hide")%>' id='DiscountRate'>Discount Rate:<br><input type="text" Id='dbF5' name='dbF5' value='<%=dLocal("dbF5")%>' readonly="readonly" size=6>%</td>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Retail" Or dLocal("dbContractType2") =  "MOTO" Or dLocal("dbContractType2") =  "Wireless" Or dLocal("dbContractType2") =  "Check Guarantee" Or dLocal("dbContractType2") =  "Check 21", "show", "hide")%>' id='TransFee'>Transaction Fee:<br>$<input type="text" Id='dbF8' name='dbF8' value='<%=dLocal("dbF8")%>' readonly="readonly" size=6></td>		
							<td class='<%=IfElse(dLocal("dbContractType2") = "Retail" Or dLocal("dbContractType2") =  "MOTO" Or dLocal("dbContractType2") =  "Wireless" Or dLocal("dbContractType2") =  "Check Guarantee" Or dLocal("dbContractType2") =  "Check 21", "show", "hide")%>' id='DebitTrans'>Debit Transaction Fee:<br>$<input type="text" Id='dbF14' name='dbF14' value='<%=dLocal("dbF14")%>' readonly="readonly" size=6></td>
						</tr>
						<tr>
							<td class='' colspan=5><img src='image/empty.gif' width=100% height=10></td>
						</tr>
						<tr class='Red'>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Retail" Or dLocal("dbContractType2") =  "MOTO" Or dLocal("dbContractType2") =  "Wireless" Or dLocal("dbContractType2") =  "Check Guarantee" Or dLocal("dbContractType2") =  "Check 21", "show", "hide")%>' id='Statement'>Statement Fee:<br>$<input type="text" Id='dbF13' name='dbF13' value='<%=dLocal("dbF13")%>' readonly="readonly" size=6></td>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Retail" Or dLocal("dbContractType2") =  "MOTO" Or dLocal("dbContractType2") =  "Wireless" Or dLocal("dbContractType2") =  "Check Guarantee" Or dLocal("dbContractType2") =  "Check 21", "show", "hide")%>' id='Minimum'>Monthly Minimum:<br>$<input type="text" Id='dbF11' name='dbF11' value='<%=dLocal("dbF11")%>' readonly="readonly" size=6></td>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Retail" Or dLocal("dbContractType2") =  "MOTO" Or dLocal("dbContractType2") =  "Wireless" Or dLocal("dbContractType2") =  "Check Guarantee" Or dLocal("dbContractType2") =  "Check 21", "show", "hide")%>' id='Membership'>Membership Fee:<br>$<input type="text" Id='dbF20' name='dbF20' value='<%=dLocal("dbF20")%>' readonly="readonly" size=6></td>
						</tr>
						<tr>
							<td class='' colspan=5><img src='image/empty.gif' width=100% height=10></td>
						</tr>
						<tr class='Red'>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Retail" Or dLocal("dbContractType2") =  "MOTO" Or dLocal("dbContractType2") =  "Wireless" Or dLocal("dbContractType2") =  "Check Guarantee" Or dLocal("dbContractType2") =  "Check 21", "show", "hide")%>' id='AVS'>AVS Surcharge:<br>$<input type="text" Id='dbF17' name='dbF17' value='<%=dLocal("dbF17")%>' readonly="readonly" size=6></td>
						</tr>
						<tr>
							<td class='' colspan=5><img src='image/empty.gif' width=100% height=10></td>
						</tr>
						<tr class='Red'>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Check Guarantee", "show", "hide")%>' id='CheckRate'>Check Rate:<br><input type="text" Id='dbF40' name='dbF40' value='<%=dLocal("dbF40")%>' readonly="readonly" size=6>%</td>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Check Guarantee", "show", "hide")%>' id='CheckTrans'>Check Transaction Fee:<br>$<input type="text" Id='dbF41' name='dbF41' value='<%=dLocal("dbF41")%>' readonly="readonly" size=6></td>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Check Guarantee", "show", "hide")%>' id='CheckStatement'>Statement Fee:<br>$<input type="text" Id='dbF42' name='dbF42' value='<%=dLocal("dbF42")%>' readonly="readonly" size=6></td>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Check Guarantee", "show", "hide")%>' id='CheckMin'>Minimum:<br>$<input type="text" Id='dbF43' name='dbF43' value='<%=dLocal("dbF43")%>' readonly="readonly" size=6></td>
						</tr>
						<tr>
							<td class='' colspan=5><img src='image/empty.gif' width=100% height=10></td>
						</tr>
						<tr class='Red'>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Auth.net", "show", "hide")%>' id='AuthSetup'>Setup Fee:<br>$<input type="text" Id='dbF23' name='dbF23' value='<%=dLocal("dbF23")%>' readonly="readonly" size=6></td>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Auth.net", "show", "hide")%>' id='AuthMonthly'>Monthly Fee:<br>$<input type="text" Id='dbF22' name='dbF22' value='<%=dLocal("dbF22")%>' readonly="readonly" size=6></td>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Auth.net", "show", "hide")%>' id='AuthTrans'>Gateway Trans Fee:<br>$<input type="text" Id='dbF24' name='dbF24' value='<%=dLocal("dbF24")%>' readonly="readonly" size=6></td>
						</tr>
						<tr>
							<td class='' colspan=5><img src='image/empty.gif' width=100% height=10></td>
						</tr>
						<tr class='Red'>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Wireless", "show", "hide")%>' id='WirelessSetup'>Wireless Setup Fee:<br>$<input type="text" Id='dbF26' name='dbF26' value='<%=dLocal("dbF26")%>' readonly="readonly" size=6></td>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Wireless", "show", "hide")%>' id='WirelessMonthly'>Wireless Access Fee:<br>$<input type="text" Id='dbF25' name='dbF25' value='<%=dLocal("dbF25")%>' readonly="readonly" size=6></td>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Wireless", "show", "hide")%>' id='WirelessTrans'>Wireless Trans Fee:<br>$<input type="text" Id='dbF27' name='dbF27' value='<%=dLocal("dbF27")%>' readonly="readonly" size=6></td>
						</tr>
						<tr>
							<td class='' colspan=5><img src='image/empty.gif' width=100% height=10></td>
						</tr>
						<tr class='Red'>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Check 21", "show", "hide")%>' id='Check21NP'>Not Present Rate:<br><input type="text" Id='dbF44' name='dbF44' value='<%=dLocal("dbF44")%>' readonly="readonly" size=6>%</td>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Check 21", "show", "hide")%>' id='Check21F2F'>Face to Face Rate:<br><input type="text" Id='dbF45' name='dbF45' value='<%=dLocal("dbF45")%>' readonly="readonly" size=6>%</td>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Check 21", "show", "hide")%>' id='Check21Trans'>Transaction Fee:<br>$<input type="text" Id='dbF46' name='dbF46' value='<%=dLocal("dbF46")%>' readonly="readonly" size=6></td>
							<td class='<%=IfElse(dLocal("dbContractType2") = "Check 21", "show", "hide")%>' id='Check21Payroll'>Payroll Cashing:<br>$<input type="text" Id='dbF47' name='dbF47' value='<%=dLocal("dbF47")%>' readonly="readonly" size=6></td>
						</tr>
						</table></td>



Default value at page load

Set dTemp = ReadRecord (localTableName, ID)
	If "" & dTemp("dbF5")="" Then dTemp("dbF5")="1.299"
	If "" & dTemp("dbF8")="" Then dTemp("dbF8")="0.15"
	If "" & dTemp("dbF13")="" Then dTemp("dbF13")="10.00"
	If "" & dTemp("dbF11")="" Then dTemp("dbF11")="25.00"
	If "" & dTemp("dbF20")="" Then dTemp("dbF20")="49.99"
	If "" & dTemp("dbREIN")="" Then dTemp("dbREIN")="261030001"
	If "" & dTemp("dbF14")="" Then dTemp("dbF14")="0.35"
	If "" & dTemp("dbF17")="" Then dTemp("dbF17")="0.05"
	If "" & dTemp("dbF25")="" Then dTemp("dbF25")="17.00"
	If "" & dTemp("dbF26")="" Then dTemp("dbF26")="50.00"
	If "" & dTemp("dbF27")="" Then dTemp("dbF27")="0.05"
	If "" & dTemp("dbF22")="" Then dTemp("dbF22")="20.00"
	If "" & dTemp("dbF23")="" Then dTemp("dbF23")="95.00"
	If "" & dTemp("dbF24")="" Then dTemp("dbF24")="0.10"
	If "" & dTemp("dbF40")="" Then dTemp("dbF40")="1.899"
	If "" & dTemp("dbF41")="" Then dTemp("dbF41")="0.25"
	If "" & dTemp("dbF42")="" Then dTemp("dbF42")="5.00"
	If "" & dTemp("dbF43")="" Then dTemp("dbF43")="15.00"
	If "" & dTemp("dbF44")="" Then dTemp("dbF44")="2.95"
	If "" & dTemp("dbF45")="" Then dTemp("dbF45")="1.95"
	If "" & dTemp("dbF46")="" Then dTemp("dbF46")="0.25"
	If "" & dTemp("dbF47")="" Then dTemp("dbF47")="3.00"

Open in new window

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE