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!

dynamic html with vbscript, non?

Status
Not open for further replies.

Dvarkholm

Technical User
Sep 5, 2002
17
0
0
GB
I must be a complete thicky. It seems to me that what you can do with javascript, you cannot do with vbscript. And that is simply dynamically modifying (updating) a browser document (or web page) or dynamically creating a browser document. Using document.write in javascript allows you to do both the above whereas I have found nothing, sorry let me make that clear NOTHING that helps me with regards accomplishing the above.

I guess that everyone knows how to do this and that explains why I can't find anything on the net or get answers to my previous topics. Surely, someone must know and be kind enough to divulge the secret to a very fustrated vbscript newbie?

I'm using vbscript because thats what I've been told to use. Otherwise I would most definitely use javascript for the client scripting that I need to do.

Maybe I should suggest to my 'superiors' that using jscript might be better with stuff that needs to access files in vbscript.

ok, sorry for the dribble, but by god I'm fustrated with the lack of forward movement on this subject.
 
Thanks for responding.

But, no, response.write is server side.

I'm only interested in client side. Document.write in vbscript creates a new page (or writes to a new page hence obliterating everything that existed in the present document). Whereas in javascript document.write writes to the present document - that's all I want to achieve but with vbscript, ie dynamically updating the client side document.
 
<script type=&quot;text/vbscript&quot;>
document.write(&quot;Hello from VBScript!&quot;)
</script>

does using the script tag above make any difference? Nick (Web Developer)


nick@retrographics.co.uk
 
take this script I wrote and please try to explain what it is that is different to you.
<html>
<head>
<script language=&quot;vbscript&quot;>
function writeItVBS()
dim wrv
wrv = &quot;I wrote this dynamicaly at &quot; & time
frm.written.value = wrv
end function
</script>
<script language=&quot;javascript&quot;>
function writeItJS()
{
var the_date = new Date();
var wr = &quot;I wrote this dynamicaly at &quot;;
wr = wr + the_date;
frm.written.value = wr;
}
</script>
</head>
<body>
<form name=&quot;frm&quot;>
<input type=&quot;button&quot; value=&quot;write some text&quot; style=&quot;background:#000000;font-size:12px;color:#ffffff;&quot; onClick=&quot;writeItJS()&quot;>
<input type=&quot;button&quot; value=&quot;write some text&quot; style=&quot;background:#000000;font-size:12px;color:#ffffff;&quot; onClick=&quot;writeItVBS()&quot;>
<input type=&quot;text&quot; name=&quot;written&quot; size=&quot;100&quot; value=&quot;&quot; style=&quot;border:none;&quot;>
</form>
</body>
</html>
admin@onpntwebdesigns.com
 
No it doesn't work. I want to use it from a vbscript function and this is quoted from the MS site:

'You should not use the write or writeln methods on the current document after the document has finished loading unless you first call the open method, which clears the current document's window and erases all variables.'

It doesn't just erase variables but the whole page and that seems to happen before and after the document has loaded.

I'm currently experimenting with outerHTML and it's family of properties. But that means having 'dummy' tags within the html page.

The point being that with javascript it was easy-peasy to accomplish what I wanted. I can't believe it's this hard to do with vbscript so I can only assume I'm missing something!

P.S. Thanks for your help.
 
if you simply write to the screen without placing it in some kind of object like a text box or such it will not work the same way.
for example change both functions above to document.writes for the variables after the click is done and it will not show the button after writing and I think that is what you are getting at is leaving all the content on the page while jsut writing some text out dynamicaly right? you can use layers to get this job done also and or div's span's etc. but you cannot just write text to a page (from what I've done in the past) in either languages retaining the page.
so this
<html>
<head>
<script language=&quot;vbscript&quot;>
function writeItVBS()
dim wrv
wrv = &quot;I wrote this dynamicaly at &quot; & time
document.write wrv
end function
</script>
<script language=&quot;javascript&quot;>
function writeItJS()
{
var the_date = new Date();
var wr = &quot;I wrote this dynamicaly at &quot;;
wr = wr + the_date;
dicument.write(wr);
}
</script>
</head>
<body>
<form name=&quot;frm&quot;>
<input type=&quot;button&quot; value=&quot;write some text&quot; style=&quot;background:#000000;font-size:12px;color:#ffffff;&quot; onClick=&quot;writeItJS()&quot;>
<input type=&quot;button&quot; value=&quot;write some text&quot; style=&quot;background:#000000;font-size:12px;color:#ffffff;&quot; onClick=&quot;writeItVBS()&quot;>
<input type=&quot;text&quot; name=&quot;written&quot; size=&quot;100&quot; value=&quot;&quot; style=&quot;border:none;&quot;>
</form>
</body>
</html>
will do exactly the same thing and not retain the button after writing to the page.
admin@onpntwebdesigns.com
 
Hang on a minute, my comment starting &quot;no it doesn't work&quot; came in after your comment starting &quot;take this script I wrote&quot;.

Ok, I have tried your code and yes thats the effect I'm getting where doing a simple document.write removes the two buttons on the screen. And yes, it does do it with javascript too!!

Ok, I'll re-examine what I did with javascript... Ah, I CREATED the page dynamically with document.writes and didn't actually do anything (eg document writes) once the page was displayed.

so yes I agree with your 2nd comment starting with &quot;if you simply write to the screen&quot;.

Ok, I need to go away and learn/experiment with what you've said eg writing to the screen by placing in objects.

Ok many thanks for your help, much appreciated.
Mark.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top