Avatar of garethtnash
garethtnash
Flag for United Kingdom of Great Britain and Northern Ireland asked on

VBScript If Statement based on Form elements

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
VB ScriptJavaScriptASP

Avatar of undefined
Last Comment
garethtnash

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
pateljitu

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
garethtnash

ASKER
Apologies for the very very delayed response; thanks for your answer
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23