Do not use on any
shared computer
September 5, 2008 08:44pm pdt
 
[x]
Attachment Details

Use of IF, Then, Else IF Statements to Control Screen Fields

Tags: JavaScript and ASP, IE 6
I am workng on a website for work and need to make a page show only one input field if it meets a certain criteria. The site is ASP and javasript was initially used for the input fileds and buttons.

When a user clicks on the button with value=<%=b_title> two fileds appears showing one input field that divides and rounds the number once they click on the "Calculate" button. Then it trasnfers that number into a readonly field. When the user feels everything looks correct then they will click on the post button or cancel to start over again.

What i  need to happen is if the fiield, <%=rslic.rows(0)("catdesc1")%> contains the word ski, then only have an input field show with a post button.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
<script language=javascript>
function ShowInput(id_val) {
var obj_id1 = document.getElementById('div1');
var obj_id2 = document.getElementById('div2');
if (id_val == 1) {
    obj_id1.style.display = "none";
    obj_id2.style.display = "";}
else {
    obj_id2.style.display = "none";
    obj_id1.style.display = "";}
}
 
function PostInput() {
n=gross1.gr_amt.value;
 
if (n == "") {
    alert('Amount cannot be blank');
    return false;
    }
if (IsNumeric(n)) {
    if (n < 0) {
        alert('Amount cannot be negative');
        return false;
        }
    else {
        return true;
        }
    }
else {
    alert('Amount must be numeric and cannot be negative');
    return false;
    }
 
}
</script>
<script language="javascript">
 
function myRound(num) {
   return Math.round(num*1)/1000;
}
</script>
 
 
%>
        <div id=div1>
              <input type=button value="<%=b_title%>" onClick=ShowInput(1)>
        </div>
        <div id=div2 style="display:none">Prior&nbsp;Year&nbsp;Gross&nbsp;Receipts:
          
				<INPUT NAME="Number" TYPE="TEXT" size=12>&nbsp;<INPUT TYPE="BUTTON" value="Calculate" ONCLICK="this.form.gr_amt.value=myRound(this.form.Number.value).toFixed(0);">
				<br>
				<br>
Calculated Gross <input name=gr_amt type=text size=9 style="text-align:right" value=<%=rslic.rows(0)("gross_rec_amt")%> readonly onFocus="this.blur()" >
              <input class="buttonsub" type="submit" value="Post" onClick="return PostInput()">
              <input class="buttonsub" type=button value="Cancel" onClick=ShowInput(2)>
        </div>
<% end if %>
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: cslt
Question Asked On: 06.03.2008
Participating Experts: 1
Points: 400
Views: 0
Translate:
Loading Advertisement...
 
[+][-]Expert Comment by hielo

Rank: Genius

Expert Comment by hielo:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by cslt
Author Comment by cslt:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34 / EE_QW_2_20070628