Solved

VBScript If Statement based on Form elements

Posted on 2012-03-14
2
383 Views
Last Modified: 2012-04-23
Hi

I want to display hidden some of the elements on my form based on a recordset value, and OR a listbox option..

I've managed to get this far --

<li<%If ISNULL(RSAccountDetail("EnewsPackage"))  Then %> style="display:none;"<%End if%>>

However I also want to hide / display based on the listbox above...

So have tried this --

<li<%If ISNULL(RSAccountDetail("EnewsPackage"))  OR select.EnewsAccountType = "" Then %> style="display:none;"<%End if%>>

So --

If the column value is NULL, OR the Select EnewsAccountType is Empty - don't display....

If the recordset column is null, but a visitor selects a value from EnewsAccountType the area is no longer hidden..

I know this can be done in Javascript, can it also be done in VBScript?

Either way,.. Javascript / VBScript -- Please can you let me know how best to write the statement please.

Thanks

My code currently looks like --

<li>
            <label>ENews Account  *</label>
            <select name="EnewsAccountType" class="inputselect2" id="EnewsAccountType">
              <option value="" <%If (Not isNull((RSAccountDetail.Fields.Item("EnewsPackage").Value))) Then If ("" = CStr((RSAccountDetail.Fields.Item("EnewsPackage").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>>Select</option>
              <%
While (NOT RSEnewsPackages.EOF)
%>
              <option value="<%=(RSEnewsPackages.Fields.Item("ID").Value)%>" <%If (Not isNull((RSAccountDetail.Fields.Item("EnewsPackage").Value))) Then If (CStr(RSEnewsPackages.Fields.Item("ID").Value) = CStr((RSAccountDetail.Fields.Item("EnewsPackage").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%> ><%=(RSEnewsPackages.Fields.Item("Name").Value)%></option>
              <%
  RSEnewsPackages.MoveNext()
Wend
If (RSEnewsPackages.CursorType > 0) Then
  RSEnewsPackages.MoveFirst
Else
  RSEnewsPackages.Requery
End If
%>
            </select>
              </li>
          <li<%If ISNULL(RSAccountDetail("EnewsPackage")) Then %> style="display:none;"<%End if%>>
            <label>Enews Join Date</label>
            <input type="text" id="EnewsStartDate" name="EnewsStartDate"  class="datebox" />xxxx  
          </li>
          
          <li<%If ISNULL(RSAccountDetail("EnewsPackage")) Then %> style="display:none;"<%End if%>>
            <label>Username *</label>
            <input name="EnewsUN" type="text" class="inputboxname" id="EnewsUN" value="<%=(RSAccountDetail.Fields.Item("EnewsUsername").Value)%>" maxlength="200" />
          </li>

Open in new window


Thanks All
0
Comment
Question by:garethtnash
2 Comments
 
LVL 15

Accepted Solution

by:
pateljitu earned 500 total points
ID: 37720696
Please make following changes to your code, line numbers are based on code submitted with this post:

Line 3:
<select name="EnewsAccountType" class="inputselect2" id="EnewsAccountType" onchange="javascript:callFunction(this.value);">

Line 20:
 <li<%If ISNULL(RSAccountDetail("EnewsPackage")) Then %> style="display:none;"<%End if%>  id="liEnewsStartDate">

Line 25:
<li<%If ISNULL(RSAccountDetail("EnewsPackage")) Then %> style="display:none;"<%End if%> <li<%If ISNULL(RSAccountDetail("EnewsPackage")) Then %> style="display:none;"<%End if%>>>

After Line 28:
<script type="text/javascript" language="javascript">
    function callFunction(obj){
        if(obj != ''){
            document.getElementById("liEnewsStartDate").style.display = "";
            document.getElementById("liEnewsUN").style.display = "";
        }
        else if(obj == ''){
            document.getElementById("liEnewsStartDate").style.display = "none";
            document.getElementById("liEnewsUN").style.display = "none";
        }
    }
</script>
0
 

Author Comment

by:garethtnash
ID: 37801574
Apologies for the very very delayed response; thanks for your answer
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now