Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Value from Select box

Status
Not open for further replies.

ashishk04

Technical User
Jan 5, 2011
1
IN
In my HTML page, I have used a select box. In it are various course options. I need to display the fee of the course in the text box according to the option selected by user.
Pls help me with my script:
Code:
<script language="VBScript">
Sub Fee()
dim a,b
b=document.subscribe.course.selectedindex
a=document.subscribe.course.options(b).value
If (a=blank) Then
MsgBox("Please select a course!")
End If
If (a=all) Then
subscribe.txtfee.value="Rs. 3000"
End If
If (a=platinum) Then
subscribe.txtfee.value="Rs. 2500"
End If
If (a=gold) Then
subscribe.txtfee.value="Rs. 2000"
End If
If (a=silver) Then
subscribe.txtfee.value="Rs. 1500"
End If
If (a=bronze) Then
subscribe.txtfee.value="Rs. 1000"
End If
If (a=contests) Then
subscribe.txtfee.value="Rs. 500"
End If
End Sub
</script>
.
.
.
<select name="course">
<option selected value="blank">&nbsp;</option>
<option value="all">All-In-One</option>
<option value="platinum">Platinum Photography Course (2 Years)</option>
<option value="gold">Gold Photography Course (1 year)</option>
<option value="silver">Silver Photography Course (6 months)</option>
<option value="bronze">Bronze Crash Course (3 months)</option>
<option value="contests">Monthly Contests</option>
</select>

<input type="button" name="btnfee" value="Check Fee" OnClick="Fee()">

<input type="text" name="txtfee" size=40 maxlength=35>
 
[0] You've not shown what the control of "subscribe" is. It should be a form element with the said name wrapping the input and select-one elements... shown. If it is at present not so, you have to make the change to it accordngly.
[tt]
<form name="subscribe"> <!-- plus other attributes according to need -->
<!-- select, input... etc as shown -->
</form>
[/tt]
[1] One instance shown; the others, similarly.

>If (a=blank) Then
[tt]If a="blank" Then 'case-sensitive "blank"[/tt]

[2] One instance shown; the others, similarly.

>subscribe.txtfee.value="Rs. 3000"
[tt]document.subscribe.txtfee.value="Rs. 3000"[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top