473,659 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VBScript/CSS problem (display property)


I'm having some trouble getting something to work. I'm not even sure
whether or not this is possible, but it *seems* like it should be.
I've done a fair amount of experimenting and googling...but maybe I'm
still missing something obvious...

I'm trying to have a <div> appear and disappear based on what a
switchbox is set to. Having <div style="display: none;"> and then
setting the display property to inline onChange works fine, but I
can't make it disappear again when I onChange back to another value.
I have tried this various ways (including having an invisible class
and changing the class rather than the display property directly) and
I can't figure out a way to have it appear when the switchbox is set
to one value, and disappear if the switchbox is set to another value.
I also can't use OnLoad to set the display property of the div to
none, it has to be set in the div tag itself...which is another reason
why I suspect I'm doing something wrong.

The visibility property is no good because I don't want the div to
take up space.

Here is an example page that doesn't work in any version of IE I have
tried it in (reformatted for USENET..sorry about the readability).
It's set up this way because I need to use the same function for
different switchboxes and <div>'s. This is for a massive form/table
so a separate function for each instance is no good. Any possible way
of getting the div to disappear and not take up space again after it
is made visible is welcome.

TIA

<html>
<head>
<script type="text/vbscript">
<!--
Sub DivChange (yesnobox, layername)
Dim strObjName
strObjName = "document.MainF orm." & yesnobox & ".value"
If eval(strObjName ) = "No" Then
document.getEle mentById(layern ame).style.disp lay = inline
Elseif eval(strObjName ) = "Yes" then
document.getEle mentById(layern ame).style.visi bility = hidden
End If
End Sub
-->
</script>

</head>
<body>
<form name="mainform" >
<select id="test" name="CD-ROM required" class="normal"
onChange="DivCh ange 'test', 'test1'">
<option selected>
<option value="Yes">Yes
<option value="No">No</select>
<div id="test1" style="display: none;">testtest esttest</div>
</form>
</html>
-- endus -- at -- endus -- dot -- com --
Not knowing what you want out of life is a pattern in itself,
perhaps the most rigid pattern of all. As a matter of fact
it's probably the most predominant pattern in the country
today, and just another name, in the long run, for what we
call the "American way of life". You are in a large and
very crowded boat, floating around aimlessly and complacently
in a very treacherous sea. At times I seriously regret that
I've divorced myself so completely from that pattern. Life
is much simpler that way, and very often much more pleasant.
-Hunter S. Thompson
Jul 20 '05 #1
2 13865
On Wed, 07 Apr 2004 10:44:33 -0400, in
comp.infosystem s.www.authoring.stylesheets endus <do**@email.inv alid>
wrote:

change your script to:
------------------------------
<script type="text/vbscript">
<!--
Sub DivChange (yesnobox, layername)
Dim strObjName
strObjName = "document.MainF orm." & yesnobox & ".value"
If eval(strObjName ) = "No" Then
document.getEle mentById(layern ame).style.disp lay = "block"
Elseif eval(strObjName ) = "Yes" then
document.getEle mentById(layern ame).style.disp lay = "none"
End If
End Sub
-->
</script>
------------------------------
---------------------------------------------------------------
jn****@yourpant sbigpond.net.au : Remove your pants to reply
---------------------------------------------------------------
Jul 20 '05 #2
On Wed, 07 Apr 2004 16:04:41 GMT, Jeff North
<jn****@yourpan tsbigpond.net.a u> wrote:
On Wed, 07 Apr 2004 10:44:33 -0400, in
comp.infosyste ms.www.authoring.stylesheets endus <do**@email.inv alid>
wrote:

change your script to:
------------------------------
<script type="text/vbscript">
<!--
Sub DivChange (yesnobox, layername)
Dim strObjName
strObjName = "document.MainF orm." & yesnobox & ".value"
If eval(strObjName ) = "No" Then
document.getEle mentById(layern ame).style.disp lay = "block"
Elseif eval(strObjName ) = "Yes" then
document.getEle mentById(layern ame).style.disp lay = "none"
End If
End Sub
-->
</script>
------------------------------
---------------------------------------------------------------
jn****@yourpan tsbigpond.net.a u : Remove your pants to reply
---------------------------------------------------------------


You, my friend, are the MAN. Thanks so much for the quick reply.
Note to posterity: the double quotes around the none or block are
essential!

Woohoo, it finally works!

-- endus -- at -- endus -- dot -- com --
Not knowing what you want out of life is a pattern in itself,
perhaps the most rigid pattern of all. As a matter of fact
it's probably the most predominant pattern in the country
today, and just another name, in the long run, for what we
call the "American way of life". You are in a large and
very crowded boat, floating around aimlessly and complacently
in a very treacherous sea. At times I seriously regret that
I've divorced myself so completely from that pattern. Life
is much simpler that way, and very often much more pleasant.
-Hunter S. Thompson
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
6011
by: Christopher Brandsdal | last post by:
If I have a .ASP page that runs JScript code - is it possible to include an ..ASP page that runs VBscript???
16
9343
by: Mike Schinkel | last post by:
Does anyone know if there are bugs in VBScript's GetRef()? I'm using VBScript Version 5.6.8515 on Win2003Server w/ASP. Sometimes it returns an object that VarType() says is a vbObject. Other times it returns VarType() is vbEmpty. This is driving me mad! Also, does anyone know what the properties and methods are for the object returned by GetRef()? TIA.
3
4837
by: | last post by:
This is a semi-advanced question about ASP VBScript 5.0 classes. If you're knowledegable, please lend a hand! VBScript class instances can have properties that have objects assigned to them. Borrowing R.Quinn's example from ASP101: Public Property Get Authors() if not isobject(m_Authors) then set Library = New cLibrary Call Library.GetAuthorsByBookID(Me.ID)
3
7026
by: Joe Caverly | last post by:
Hi, I'm using Visual C++ 32-bit Professional Edition 5.0 Using Microsoft Knowledge Base Article 181473 as a basis, I'm trying to transform this VB Code; Dim sc As Object Dim code As String Set sc = CreateObject("ScriptControl") sc.Language = "VBScript"
2
2848
by: Frank | last post by:
Can I do this? I add a session var in C# and ultimatly want to pass it into a vbscript client side activeX control. This is what I have so far but get " Object Required:'name2' " error. Can anyone suggest a btter way of passing a session var into a vbscript function? <%@ Page language="c#" debug="true" ContentType="text/html"
3
2970
by: Drwtsn32 | last post by:
Hi Guys, I'm ripping off all of my hair soon ;-) I'm trying to do a very simple C# form accessible from COM client like VBScript. I would like to display the form and update the form during the intepretation of the vbscript. Does anyone know of any good example that could point me to the right direction.
4
2512
by: client site dll in vbscript | last post by:
Hi i have one dll on client site,i want to use it in aspx page, on clinet site Is it possible or not .Please tell me the solution Please email me at indipren@hotmail.com Regarda Indi
1
7081
by: Michael McGrew | last post by:
I have a asp form that has a dynamic drop-down box that a user selects a value from. Once the user makes a selection I use the onChange event to capture the selection and pass this value to a vbscript sub. The sub then makes a adsi query using this value to retrieve additional information. This all works. I used a msgbox to display the retrieved value and it is correct. My problem is how do I update a field on the form with this retrieved...
2
2798
by: mdock | last post by:
Hello, I have a javascript grid on my ASP page which displays information about the history of specific units produced in our manufacturing facility. One of the results is the order number on which the unit was shipped. If the unit was not shipped, obviously there is no order number; the default value of this field on the data table is 0. Herein lies the problem; if the order number is 0, I do not want the grid to display anything. If...
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8626
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.