VBScript If Statement based on Form elements


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.


My code currently looks like --

            <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>
If (RSEnewsPackages.CursorType > 0) Then
End If
          <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<%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" />

Open in new window

Thanks All
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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";

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
garethtnashAuthor Commented:
Apologies for the very very delayed response; thanks for your answer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.