?
Solved

VBScript If Statement based on Form elements

Posted on 2012-03-14
2
Medium Priority
?
432 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
[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
2 Comments
 
LVL 15

Accepted Solution

by:
pateljitu earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
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…
Suggested Courses

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