Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbscript is fustrating

Status
Not open for further replies.

Dvarkholm

Technical User
Sep 5, 2002
17
0
0
GB
Why is it so easy to write to an existing page in javascript (using document.write) but impossible to get right in vbscript?

I'm trying to write to an existing page in vbscript but obviously I'm missing something pretty important.

Using document.write in vbscript does write to the page but it seems that the style sheet positional info is ignored or doesn't work with vbscript yet works correctly with javascript.

Also I can't find anywhere on the net that shows/describes how to accomplish things like this (but of course plenty of javascript info).

It's not that I can't do vbscript - I've been writing stuff to deal with arrays, reading external files etc etc but I am completely stuck when it comes to dynamically updating/changing the web page. Any help most appreciated.
Mark.
 
Sorry I should have said that this is simply client side scripting and I'm a vbscript newbie (and have never done vb).

Mark.
 
can you show the code you are attempting to use

writing with vbscript is not any different then javascript in the fact it will recognize your css styles. I'm guessing there is just a mistake in the code. typo!

you will not find much for client side vbscript due to only being supported by IE. BUT, it not a hard process to use asp scripts and convert to client side. I suggest searching for asp scripts in regards to what you need too accomplish and convert them. usually just the response and request substitutions.
admin@onpntwebdesigns.com
 
Thanks for responding.

Basically there is an onload=&quot;InitiatePage()&quot; bit in the <BODY> tag. Inside that function are several lines eg.,

document.write(&quot;<IMG src='leftmain.jpg' class='Logo'>&quot;)
document.write(&quot;<IMG SRC='Title2.jpg' class='Title'>&quot;)
document.write(&quot;<IMG SRC='rightmain.jpg' class='right'>&quot;)

which when done with javascript shows the title jpg at the top in between the left and right graphics. This all looks great when done with javascript and but a mess with vbscript.

There are more document.writes after that which added checkboxes to the page and graphical buttons, so the whole function is as follows:

function useProductArray()
dim intI

document.write(&quot;<IMG src='leftmain.jpg'>&quot;)
document.write(&quot;<IMG SRC='Title2.jpg'>&quot;)
document.write(&quot;<IMG SRC='rightmain.jpg'>&quot;)

document.write(&quot;<form name='ProductSelection' class='Productform'>&quot;)

document.write(&quot;<p class='generaltext'>Select the products you wish to install:</p>&quot;)
document.write(&quot;<table class='tabletext' width='317' cellspacing='0' cellpadding='0' frame='border' border='0'>&quot;)

for intI = 0 to intNumProducts-1
writeTableRowTag(1)
writeUncheckedBox(intI)
writeTableRowTag(0)
next

document.write(&quot;</table>&quot;)
document.write(&quot;</form>&quot;)


document.write(&quot;<a href='' class='barbutton1' onmouseover='MouseOver('Back')' onmouseout='MouseOut('Back')' onmousedown='saveForm(); saveCookie('Products'); location='index.html''><img src='backb.jpg' width='122' height='27' alt='Back' name='Back' border='0'></a>&quot;)
document.write(&quot;<a href='' class='barbutton2' onmouseover='MouseOver('CheckAll')' onmouseout='MouseOut('CheckAll')' onmousedown='checkall()'><img src='checkallb.jpg' width='122' height='27' alt='Check all' name='CheckAll' border='0'></a>&quot;)
document.write(&quot;<a href='' class='barbutton3' onmouseover='MouseOver('UnCheckAll')' onmouseout='MouseOut('UnCheckAll')' onmousedown='uncheckall()'><img src='uncheckallb.jpg' width='122' height='27' alt='Uncheck all' name='UnCheckAll' border='0'></a>&quot;)
document.write(&quot;<a href='' class='barbutton4' onmouseover='MouseOver('Install')' onmouseout='MouseOut('Install')' onmousedown='productSelected()'><img src='installb.jpg' width='122' height='27' alt='Install selected products' name='Install' border='0'></a>&quot;)
end function

All the elements are displayed on the page but in the order they are created above and not in the correct position as described in the style sheet.

As a slight aside, clicking on any of the button graphics produces an error 'object expected at line 0'. Line 0 is <HTML>

Thanks,
Mark.
 
sorry, typo in msg, the code in the lines:

document.write(&quot;<IMG src='leftmain.jpg'>&quot;)
document.write(&quot;<IMG SRC='Title2.jpg'>&quot;)
document.write(&quot;<IMG SRC='rightmain.jpg'>&quot;)

should include (and do in real life) the class reference.
Mark.

 
Interesting!

If I replace those three img src code lines with:

document.write(&quot;<IMG STYLE='position:absolute; top:0; left:0; z-index:-1' SRC='leftmain.jpg'>&quot;)
document.write(&quot;<IMG STYLE='position:absolute; top:0; left:400; z-index:-1' SRC='rightmain.jpg'>&quot;)
document.write(&quot;<IMG STYLE='position:absolute; top:0; left:150; z-index:-1' SRC='Title2.jpg'>&quot;)

I can get them into the 'correct' position.
Which suggests the style sheet is accessible, but it is. Because the html file is in the same dir as the css file.
 
This is a stupid question but
are you linking to the style sheet. I know that sounds stupid but it sounds like you may think if the sheet is just in the same directory it will find the class. Is this in the head of you page someone.
<link rel=&quot;stylesheet&quot; href=&quot;style.css&quot; type=&quot;text/css&quot;>
admin@onpntwebdesigns.com
 
Just checked and its thus:

<LINK REL=StyleSheet HREF=&quot;index.css&quot; TYPE=&quot;text/css&quot; MEDIA=screen>

I put &quot;&quot; around the REL and MEDIA values, but nope, no change :-(
 
Of course, that make not work because I read somewhere that document.write in vbscript creates a new page so effectively getting rid of everything (including the reference to the style, functions etc).

So if that is correct... how the heck do I do what I did in javascript with document.write but in vbscript???
 
well, you educated me today. I did some messing around with this issue and could not come to a conclusion on linking to a style sheet with the write in vbscript. The only thing I can say unless someone else has input is to write them out like you had figured above in the inline
here's what I tried if your interested. real simple but could not get it too work without a inline style
<html>
<head>

<script language=&quot;vbscript&quot;>
document.write(&quot;<LINK REL='StyleSheet' HREF='buttons.css' TYPE='text/css'>&quot;)
document.write(&quot;<input type='button' value='help' class='black'>&quot;)
document.write(&quot;<input type='button' value='help' class='yellow'>&quot;)
document.write(&quot;<input type='button' value='help' style='color:#FFFFFF; background-color:black;border-color: white;'>&quot;)
</script>
</html>
buttons.css
.blue {color:#FFFFFF; background-color:blue;}
.yellow {color:#FFFFFF; background-color:yellow;}
.black {color:#FFFFFF; background-color:black;}

sorry I have no solution
admin@onpntwebdesigns.com
 
I'm not familiar with document.write. I use response.write. Don't know if it would make any difference but...worth a try?
mb
:) &quot;Where's the Ka-Boom? There's supposed to be an Earth-shattering Ka-Boom!&quot;
Marvin the Martian
 
Thanks for your help chaps.

In the Message &quot;Vbscript fails to update screen&quot; or thread 329-205466, dilettante states that document.write is not intended for general dhtml but rather for 'pre-pageload' scripting or for creating a fresh page.

So as I'm a relative newbie to vbscript, how do I update/change the contents of a page thats already displayed. Easy to do in javascript, but not it seems to me in vbscript.

Any help appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top