Solved

VBScript If Statement based on Form elements

Posted on 2012-03-14
2
429 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 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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

688 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