navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

VBScript question

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> VBScript question
Page: [1]
 
sarge

 

Posts: 376
From: London England
Status: offline

 
VBScript question - 1/10/2002 10:22:26   
Hi-
I have a page with some checkboxes which, when clicked, alter the characteristics of a table, and I'm doing this with VBScript.
For example, if I want to flip-flop a border around the table, I do:
Select case window.event.srcElement.id
Case "boxed"
if mytable.border = "4" then
mytable.border = "0"
else
mytable.border = "4"
end if
This works fine. The problem is that I can't find the right syntax to do the same with bgcolor. If I do:
Case "bright"
if mytable.bgcolor = "#FFFF66" then
mytable.bgcolor = "#FFFFCC"
else
mytable.bgcolor = "#FFFF66"
end if
It always takes the else path, and I can't find any syntax that gets recognised (even though the browser recognises the else value when it gets inserted).

Any ideas?
Thanks, Sarge



 
ginnie

 

Posts: 527
From: St. Louis MO USA
Status: offline

 
RE: VBScript question - 1/10/2002 11:51:45   
I believe that should be "background-color".



ginnie
Global Presence Web Design

(in reply to sarge)
sarge

 

Posts: 376
From: London England
Status: offline

 
RE: VBScript question - 1/10/2002 12:46:44   
Hi Ginnie-
I've tried using background-color, but I just get 'Error on page' at run time. I've also tried the syntax "(##FFFF66)", but still no joy.

 

(in reply to sarge)
ginnie

 

Posts: 527
From: St. Louis MO USA
Status: offline

 
RE: VBScript question - 1/10/2002 12:57:35   
Do you have a url?

Or can you post the entire code?

ginnie
Global Presence Web Design

(in reply to sarge)
sarge

 

Posts: 376
From: London England
Status: offline

 
RE: VBScript question - 1/10/2002 18:24:04   
Hi Ginnie-

These are the relevant bits of HTML, extracted from the page.
(The page itself is rather large)

1.) This is the SCRIPT

<SCRIPT language="VBSCRIPT">
sub document_onclick
Select case window.event.srcElement.id
Case "boxed"
if histable.border = "4" then
histable.border = "0"
else
histable.border = "4"
end if
Case "bright"
if histable.background-color = "#FFFF66" then
histable.background-color = "#FFFFCC"
else
histable.background-color = "#FFFF66"
end if
Case else
exit sub
End select
end sub
</SCRIPT>

2.) This is the table 'histable':

<table id=histable width="100%" border="<%If FP_FieldVal(fp_rs,"trad_boxed")= "True" then response.write "4" else response.write "0"%>" cellspacing="0" cellpadding="3" height="20" style="background-color: <%If FP_FieldVal(fp_rs,"trad_bright")= "True" then response.write "#FFFF66" else response.write "#FFFFCC"%>" >

3.) These are the checkboxes:

<input id=boxed type="<%If FP_FieldVal(fp_rs,"trad_boxed")= "True" then response.write "hidden" else response.write "checkbox"%>" name="boxed" value="ON" <%If FP_FieldURL(fp_rs,"trad_boxed") = "True" then response.write " checked"%>>

<input id=bright type="<%If FP_FieldVal(fp_rs,"trad_bright")= "True" then response.write "hidden" else response.write "checkbox"%>" name="bright" value="ON" <%If FP_FieldURL(fp_rs,"trad_bright") = "True" then response.write " checked"%>>

------------------------------------
Just in case you're wondering, the object of the page is this:
The site has a directory of computer traders in London, and this page allows traders to 'play with' the way that their details are presented. Its a bit like yellow pages (where you can box entries, change the font size, the background color etc.). Checkboxes get hidden when the trader takes up an option (for a year).
------------------------------------

Anyway, thanks in advance,
Sarge

 

(in reply to sarge)
ginnie

 

Posts: 527
From: St. Louis MO USA
Status: offline

 
RE: VBScript question - 1/10/2002 21:36:30   
Hmmm...I don't know. I've not done any scripting that changes styles. My only other suggestion would be to try bgColor.

Note: I'm moving this thread to the database forum where the VB Scripters hang out.

ginnie
Global Presence Web Design

(in reply to sarge)
sarge

 

Posts: 376
From: London England
Status: offline

 
RE: VBScript question - 1/10/2002 22:32:22   
Thanks Ginnie-
I tried bgcolor. It doesn't give an error, but it doesn't seem to recognise syntax like:

if histable.bgcolor = "#FFFFCC" then...

It always takes the 'not equal' path.

Why is syntax such a pain? With a bit more programming effort, I'm sure that many languages could be much more accommodating without being inaccurate. This exercise should be sooo easy...
Anyway, if I can't find the answer, I'll have to resort to DIVs & layers & visibilities & things. And that really will be a pain.

 

(in reply to sarge)
Mojo

 

Posts: 2431
From: Chicago
Status: offline

 
RE: VBScript question - 1/11/2002 0:25:10   
If I understand what your after, the following works. I did not use a style in the table, just bgColor="#000066" (which you can change dynamically). The else statement is NOT chosen because the If is true. This is easily shown by the message box not popping up or you could change the table bgColor to something else besides #000066.

Here goes:

<table id=histable width="100%" bgColor="#000066">
<tr>
<td>Chicago</td>
</tr>
</table>
<SCRIPT language="VBSCRIPT">

If histable.bgColor = "#000066" Then
histable.bgColor = "#cccccc"
Else
myColor = histable.bgColor
alert(mycolor)
histable.bgColor = "red"
End If

</SCRIPT>


Joe


(in reply to sarge)
sarge

 

Posts: 376
From: London England
Status: offline

 
RE: VBScript question - 1/11/2002 10:00:23   
Hi Joe-

Its working. I've finally found out what was happening. And I'm gobsmacked.

I was doing:
if histable.bgcolor = "#FFFFCC"
I should have been doing:
if histable.bgcolor = "#ffffcc"

Although FP represents the hex values in upper case in the HTML, they seem to get surreptitiously converted to lower case somewhere along the way.

Anyway, many thanks for your help. It was only by making liberal use of your alert boxes that I spotted it. Perhaps I should buy a book on VBScript.
Or maybe I should be put out to grass...

Regards,
Sarge


 

(in reply to sarge)
Mojo

 

Posts: 2431
From: Chicago
Status: offline

 
RE: VBScript question - 1/11/2002 10:33:01   
Glad you got it!


(in reply to sarge)
ginnie

 

Posts: 527
From: St. Louis MO USA
Status: offline

 
RE: VBScript question - 1/11/2002 10:39:33   
When I recommended byColor, I was referring to the upper case "C" instead of just "bgcolor". I remember that in JavaScript, it had to be an upper case C.

Glad you got it working though.

Edit: Just curious for future reference, in your working version, are you using bgcolor (like you originally used) or bgColor (as shown in Joe's example)?

ginnie
Global Presence Web Design

Edited by - ginnie on 01/11/2002 11:43:10

(in reply to sarge)
sarge

 

Posts: 376
From: London England
Status: offline

 
RE: VBScript question - 1/11/2002 11:20:15   
Could I ask you another 'quickie'?
I now need to do the same sort of thing with font size and font color. Can these be changed dynamically? I'm not having much luck so far...
Thanks,
Sarge

 

(in reply to sarge)
sarge

 

Posts: 376
From: London England
Status: offline

 
RE: VBScript question - 1/11/2002 13:14:39   
Skip that. Style works.
e.g. hisname.style.color = "#708090"

Amen. (I hope)

 

(in reply to sarge)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> VBScript question
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts