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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

document.write vs. response.write? 2

Status
Not open for further replies.

Ovatvvon

Programmer
Feb 1, 2001
1,514
US
Is there a difference between the document.write and response.write? What is it? And when would you want to use each one?

-Ovatvvon
 
Response.Write is ASP server-side write of string containing HTML.
Document.Write is client-side write of HTML to browswer object.
If you need more than that get a book on ASP.
 
document.write -writes the data on the screen from clientside in javascript.

response.write -writes data on screen from server side in asp
 
Why would you use a document.write then when you can simply write the code out? What would be the advantage, or purpose?
 
Right, But you don't have to put it inside a document.write to write it to the client side, if I put in:


-----------------------------------------------------
<html>
<head>
<title>My Form Test</title>

<script language=&quot;javascript&quot;>
<!--
function checkForm(form){
if(form.name.value == &quot;&quot;){
alert(&quot;Enter your information&quot;);
form.name.focus();
return false;
}
if(form.name.value.length < 3){
alert(&quot;You must enter at least 3 characters&quot;);
form.name.focus();
return false;
}
else{
return true;
}
}
-->
</script>

</head>
<body bgcolor='white' text='black'>


<br>
<DD><DD>
<table border=0><tr><td>
<form onSubmit='return checkForm(this)' method='post' action='nextpage.asp'>
Enter Your Name:<BR>
<input type='text' name='name'><BR>
<input type='submit' value='Submit'>
</form>
</td></tr></table>



</body>
</html>
----------------------------------------------------

that works fine. Why would I want to use the document.write?
 
To Ovatvvon's comment about why you would want to response.write client side code with server side code...

What if you had a variable in server side code that you wanted to get into client side code?

You don't have to do it all the time, but it can be VERY useful in certain cases...

faq329-603

:)
 
Link9,
Read the above messages, I didn't ask why you would use a server side response.write, I'm asking why you would use a client side document.write!

I know why you would use response.write, infact I use it all the time. However for client side, I don't understand why you would use document.write when you can write out the code without it just as I have above.

-Ovatvvon
 
um, you'd use a client side document.write, IF you were unable to do the Server-Side method, also client-side execution can be faster. Karl Blessing aka kb244{fastHACK}
kblogo.jpg
 
Perhaps using the capabilties of a FAT client (whatever happened to those thin clients?) will make for thinner servers and better response time e.g. client-side sorting of lists, input validation, list box population triggered by user input and fewer round trips to a server. The more you make the client react as quickly as a desktop application the better. A user should never have choises presented that he/she can not make. We've seen lists boxes that have choices that should not be selected based on a choice made in a previous list box. Only client-side logic (please, no round trip to/from the server) solves this problem by reacting locally. Otherwise, your application is no better than a mainframe &quot;green screen&quot; except with scrolling and more colors.
 
there have been numerous cases where I resorted to client-side procedures, simply because it is faster, for example Having somewhat around 100 checkboxes on the screen, and generating the behavior serverside (writing the javascript to the html) , but have the behavior executed clientside (in the javascript) is extremely quick, and takes alot less bandwidth than to roundtrip over 100 checkbox properties to the server. Karl Blessing aka kb244{fastHACK}
kblogo.jpg
 
ok, not to insult you all, but you all are stupid! I have asked numerous times why I would want to use the document.write rather than just writing out the html on the client side....the first thing I asked was the difference between the response.write, and document.write which I found the answer, but once I asked why I would want to use the document.write on the client side, those who responded went off to other topics discussing server round trips (? We're talking about client side, not server side, read first, then respond!), and people saying I'd use the document.write IF I couldn't use the server side response.write.

Come-on! If you don't know the answer, then please don't just write SOMTHING to make it look like you are smart and helpfull, wait for the right person to answer, and learn from them. But it frustrates me, as I'm sure it does to others too, to see people respond to a question with answer that has nothing to do with the question!

Thank you,

- Ovatvvon
 
Sure is rough to see you get your pannies all in a bunch there, but I suppose you're right -- a few off-topic responses, and I did, in fact, read your post incorrectly, and in the (obviously vein) attempt to help someone, I posted something that you weren't asking for... boy, that's too bad...

So anywho --

Let's see... WHY would I use document.write client side for anything when I could just type out the code --

Well, I suppose if I had a client side variable that I wanted to write out to the screen, I might decide to use document.write. Where the variable was something calculated. For example, there are two text boxes that someone can put numbers in, and I want to write a function to add those two numbers together and write them to a table cell -- just a for instance...


So now for people being stupid -- let's take a step back, and read this thread from top to bottom. If I was someone that wanted to know the difference between the two, I would have to say that this thread explains it pretty well. In fact, I would take that one step further to say that this thread represents the essence of what this site is all about. Discussion. Yes, a few off topic posts, BUT many bases were covered above and beyond what your post was even about. Yes, I think that I will just copy this thread and paste it into a text file so that I can read it (in all its stupidness) in the future to review exactly what the difference is between the two.

I hope lots of people in the future try to be as &quot;stupid&quot; as they were in this thread, so that this site will continue to be as &quot;stupid&quot; as it currently is.

Here's to the &quot;stupid&quot;est site on the net! HERE HERE!!
--
 
Thank you Link9 for explaining that to me. I do understand it a little better now.

Also, that wasn't an insulting &quot;stupid&quot;, that was to say that the people didn't pay attention as I exlpained...but obviously you WERE insulted, so if that is true, I appologize. I'm sorry for making any derogotory comments that would have offended you. :)

ya'll have a nice day.

-ovatvvon
 
Ovatron:
You would want to use Document Write on the client side for a dynamic web page that uses Java script.

One instance would be a calculator.
Document.write is called for each cell in the calculator.

If I'm wrong and thats some other part of Jscript that does that then let me know.

Programmers know you need document.write :) because the text needs to be assimilated on the client side like someone stated above- appending strings, taking out spaces,

Personally I hate Jscript and only use ASP and regular HTML since I come from a C++ background. Shockwave is good for if you want good control of graphics, especially movement (games, animations)

To mix server side scripting, client side scripting where Jscript has different order of operations than ASP on server side and also HTML with Jscript affects Jscripts function order of operations in some circumstances leading to hell when it could be done with Shockwave (yeh shockwave isn't real code but its closer than Jscript/html/style sheots/HexML -
I'm more tangents than a trig class :)
You'd say huh? Me too.

-Stylin/
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top