...

View Full Version : JS Output?



Erindesign
10-12-2006, 09:29 PM
What would be the valid output for javascript? (like php has echo, c++ has cout)I tried looking on google but couldn't find anything.

I'm trying to make a simple, very simple script in javascript. I was going to use php but it didn't really work out. CuteNews doesn't accept php in their templates?

it looks something like this in php


<?php
if($countnews<10){
echo("<tr><td class=\"side\">{date}: {short-story}</td></tr>");}
else{
echo("<tr><td class=\"sidebottom\">{date}: {short-story}</td></tr>");}
$countnews=$countnews+1;
?>


$countnews is declared at the head of the document as 0. When the news displayed gets to 10, it will change the class of the cell to sidebottom.

Like I said, it doesn't work in php because cutenews doesn't allow it for some reason. Can anyone take 30 seconds and convert that to javascript?

Kravvitz
10-12-2006, 09:39 PM
So modify Cute News.

This is something that should be done server-side -- not with JavaScript.

Keep in mind that some Internet users use a browser that doesn't have JavaScript enabled. (http://www.thecounter.com/stats/2006/September/javas.php)

JavaScript is very different from server-side languages. There are multiple ways to add things to the document. The best way is to use the Document Object Model (DOM).
Rough Guide to the DOM (http://www.sitepoint.com/article/rough-guide-dom/)
JavaScript tutorial - W3C DOM introduction (http://www.howtocreate.co.uk/tutorials/javascript/domintroduction)
http://www.quirksmode.org/dom/
http://www.quirksmode.org/js/dom.html
http://www.brainjar.com/
http://developer.apple.com/internet/webcontent/dom2i.html
http://developer.mozilla.org/en/docs/DOM:document
http://developer.mozilla.org/en/docs/Gecko_DOM_Reference
http://digital-web.com/articles/forms_usability_and_the_w3c_dom/
http://www.w3.org/DOM/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum