JavaScript - Putting A Comment Function Into My Html/css Page
Hello, I have not been able to do any JS because my damn books have been on order for the last 3 weeks but I'm wondering if anybody could help me put a script into my webpage so that when anybody visits the 'contact us' page they can leave comments.
Here's my code: HTML: Code: <!DOCTYPE html "PUBLIC-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Contact Us</title> <link rel="stylesheet" type="text/css" href="css/contactus.css" /> </head> <body bgcolor="grey"> <img src="gradientheader.jpg" id="header" width="930px;" height="120px;" align="center" border="1" /> <div class="gradientbuttons blacktheme"> <ul> <li><a href="headerwithbuttons.html">Home</a></li> <li><a href="http://www.dynamicdrive.com/new.htm">Games</a></li> <li><a href="http://www.dynamicdrive.com/style/">Music</a></li> <li><a href="http://www.dynamicdrive.com/forums/">Forums</a></li> <li><a href="http://tools.dynamicdrive.com/imageoptimizer/">Contact Us</a></li> <li><a href="http://www.codingforums.com/">Links</a></li> </ul> </div> </br> <div> <img src="contactus.jpg" id="contactusright" alt="contact1" height="120px;" /> </div> <div> <img src="contactus.jpg" id="contactusleft" alt="contact2" height="120px;" /> </div> <div class="infoarea1" height="300"> <img src="tel2.jpg" width="250" height="100px;" /> <p class="infoarea1">Please contact us on either our Fax line or Business line on:</p> <br /> <p><i>Telephone: <b>012....</b></i>;</p> <p><i>Fax: <b>012.....6</b></i></p> </div> <div class="infoarea2" height="300"> <img src="emailicon.jpg" width="250" height="100px;" /> <p class="infoarea2">Please contact us by e-mail to the following e-mail address:</p> <br /> <p><i>E-Mail: <b>flipmode...........co.uk</b></i></p> </div> <div class="infoarea3" height="300"> <img src="postboxicon.jpg" width="250" height="100px;" /> <p class="infoarea3">Please contact us by post by sending all relevant post to:</p> <br /> <p><i>..........</p> <p>............</p> <p>.......</p> <p>.......</i></p> </div> </body> </html> CSS: Code: #header {border-style: solid; border-width: 2px; border-color: black; } .gradientbuttons {position:absolute; top:95px; left:149px; } .gradientbuttons ul{ padding: 3px 0; margin-left: 0; margin-top: 1px; margin-bottom: 0; font: bold 13px Verdana; list-style-type: none; text-align: center; /*set to left, center, or right to align the menu as desired*/ } .gradientbuttons li{ display: inline; margin: 0; } .gradientbuttons li a{ text-decoration: none; padding: 3px 7px; margin-right: 50px; border: 1px solid #778; color: white; border:1px solid gray; background: #3282c2; border-radius: 8px; /*w3c border radius*/ box-shadow: 3px 3px 4px rgba(0,0,0,.5); /* w3c box shadow */ -moz-border-radius: 8px; /* mozilla border radius */ -moz-box-shadow: 3px 3px 4px rgba(0,0,0,.5); /* mozilla box shadow */ background: -moz-linear-gradient(center top, #a4ccec, #72a6d4 25%, #3282c2 45%, #357cbd 85%, #72a6d4); /* mozilla gradient background */ -webkit-border-radius: 8px; /* webkit border radius */ -webkit-box-shadow: 3px 3px 4px rgba(0,0,0,.5); /* webkit box shadow */ background: -webkit-gradient(linear, center top, center bottom, from(#a4ccec), color-stop(25%, #72a6d4), color-stop(45%, #3282c2), color-stop(85%, #357cbd), to(#72a6d4)); /* webkit gradient background */ } .gradientbuttons li a:hover{ color: red; } .blacktheme li a{ font-size:16px; background: black; background: -moz-linear-gradient(center top, #9f9f9f, #686868 25%, #2a2a2a 45%, #686868 85%, #9f9f9f); background: -webkit-gradient(linear, center top, center bottom, from(#9f9f9f), color-stop(25%, #686868), color-stop(45%, #2a2a2a), color-stop(85%, #686868), to(#9f9f9f)); } #contactusright {position: absolute; top:8px; left:895px;} #contactusright {border: 2px solid #8dcb41; width: 100px;} #contactusleft {position: absolute; top:8px; left:8px;} #contactusleft {border: 2px solid #8dcb41; width: 100px;} div.infoarea1 {float: left;} div.infoarea1 {width: 250px; background-color: green; margin-top: 20px;} p {padding: 1; margin: 5;} p {font-family: franklin gothic; color: black; } div.infoarea2 {float: left;} div.infoarea2 {width: 250px; background-color: red; margin-top: 20px; margin-left: 130px;} div.infoarea3 {float: right;} div.infoarea3 {width: 250px; background-color: blue; margin-top: 20px; margin-right: 0px; } BTW - I know this doesn't validate but it's only a draft site until I get my books. Thanks for any info! Here's the page, I want the comment underneath all three div's. Similar TutorialsHi, I am a newbie to Javascript but managed to set up a simple Function that allows me to create a thumbnail image viewer with headings and text. One of the variables is a Hyperlink. It all works fine but I want the hyperlink to open as a PopUp Window, but not sure how to do it. My Code Code: function LoadGallery(pictureName,imageFile,titleCaption,captionText,titleText,textText,titleJob,jobText,titlePricelist,pricelistText) { var picture = document.getElementById(pictureName); if (picture.filters) { picture.style.filter="blendTrans(duration=1)"; picture.filters.blendTrans.Apply(); } picture.src = imageFile; if (picture.filters) { picture.filters.blendTrans.Play(); } document.getElementById(titleCaption).innerHTML=captionText; document.getElementById(titleText).innerHTML=textText; document.getElementById(titleJob).innerHTML=jobText; document.getElementById(titlePricelist).innerHTML=pricelistText; } and in my <body>, I have this code for each thumbnail .... Quote: <a href="#_self" onclick="LoadGallery('TeamGallery', 'http://www.albionhousehairsalon.co.uk/images/theteam_sharron_lg.gif', 'TeamGalleryCaption', 'Sharron', 'TeamGalleryText', 'Some text about Sharron','TeamGalleryRole','Senior Stylist','TeamGalleryPrices','<a href=\'/albion_house_hair_salon.html\'>Click here to see Sharrons Service Price List</a>')"><img src="http://www.albionhousehairsalon.co.uk/images/theteam_sharron_thumb.gif" width="90" height="61" /></a> This can be seen working her: http://www.albionhousehairsalon.co.u..._the_team.html but what I want is when you click on the text "Click here to see Gemma's Service Price List" (specific to Gemma of course). .... her price list opens in a popup? (If you want to try this Gemma is the Director with the Burgundy haircolour, top left on the page). Can anyone help? P.S. I am using the <div class> and id to pass the variable data through the function and display the enlarged image and relevant text and hyperlink... if that makes sense ? Hi, I'm using this to put menus on my website http://simplythebest.net/scripts/DHT...script_79.html at the top it says its capable of having more than one menu on a page, but it doesnt give the directions. The website it links to for more help is dead. Can anyone help me out? I came across some embedded JavaScript code and I noticed some weird “HTML comment-like tags” within embedded JavaScript that are getting rendered in FireFox but not IE. Specifically the closing tag "//-->" And the JavaScript code between these tags is functional (not commented out)! Code: <SCRIPT type=text/javascript> <!-- .... //--> </SCRIPT> What are these? Example usage: Code: <SCRIPT type=text/javascript> <!-- var zz, zv, d, fTSR; d = new Date(); fTSR=0; zv = d.getTime(); zz = "&zz="+zv; var gBF=false; function GoTo(u){window.top.location = u + zz;} function Go(u){window.top.location = u;} .... //--> </SCRIPT> Hi, I'm trying to pass a javascript variable into a html form. The variable has to go into a dropdown box. At the moment I have the following html form: <form method="post" action="<?=$_SERVER['PHP_SELF']?>" > <select name="lightbox_select_<?=$_GET['id']?>"> <? foreach ($get_lightboxes as $lightbox) : ?> <? $lightbox_id = $lightbox["lightbox_id"]; ?> <? $title = $lightbox["title"]; ?> <? if(strlen($title) > 25) $title = substr($title, 0, 25) . "…"; ?> <option value="<?=$lightbox_id?>"><?=$title?></option> <? endforeach; ?> <option id="extra_lightbox" value=""></option> </select> <input type="submit" name="submit" value="Add" /> And the following javascript function: function get_lightboxes(title, new_lightbox_id){ document.getElementById('extra_lightbox').value = new_lightbox_id; document.getElementById('extra_lightbox').name = title; } How can I pass the 'title' and 'new_lightbox_id' variables from javascript into the extra option bit of the form#? Hello I'm not sure if I post this message on the right section or not...Actually what iam having difficulty at is I put a facebook plugin commentbox on my page. here is the link for my site http://www.mxstudio.ca/comments.html what my qestion is I can't delit other people message from this page. So if someone post badwords to my site is there anything I can remove his or her comments from this comment section. Any answer greatly precaite thanks... Hello I'm not sure if I post this message on the right section or not...Actually what iam having difficulty at is I put a facebook plugin commentbox on my page. here is the link for my site http://www.mxstudio.ca/comments.html what my qestion is I can't delit other people message from this page. So if someone post badwords to my site is there anything I can remove his or her comments from this comment section. Any answer greatly precaite thanks... Hi, I'm just now starting to try to insert some javascript into my html and php code. I'm only used to working with those two markups. I need to try some very simple javascript snippets in some forms I'm making, but am having an issue getting the code to work. When I find these snippets, they are usually in a format like this: Code: <SCRIPT LANGUAGE="JavaScript"> // functions and whatnot here function makeSomethingHappen(field, count, max) { if (something.works > true) field.value = i.will.crap(0, max); else // calculate the remaining characters field.value = max - more.nodoze.caffein; } </script> <center> <form name=sample action=""> <input type="text" name="hours"> onKeyDown="CountLeft(some.js.looking,stuff.here);" onKeyUp="CountLeft(some.more.js.looking,stuff.here);"> </form> I've tried inserting the stuff like the webpages have it listed. I also try inserting everything contained in the <script> tags into the head of the document (or creating a head and putting it in there, since all my stuff is php and html code called to the file with php includes and whatnot). Anyways, I hoping somebody can provide a pointer as to how to use these snippets or how to correctly place things like this. I'm assuming there's a relatively uniform way that people are posting their tiny little js codes and I'm missing some basic knowledge as to how to use it. Any help is greatly appreciated. I just wrote an essay to discover it had logged me out and I lost everything. Grrrrrrr. Here goes again, simplified this time. I've got a sticky footer at the bottom of the page and a spry collapsible panel which expands to reveal content on mouse over. The problem I'm facing is that the page doesn't scroll down with it, only the scroll bar gets larger to accommodate for a manual scroll down. This is kind of useless because the user might not even realise that there's extra content there in the first place if it's not automatic. My question is, what's the best javascript code to use to automatically scroll the page down when the spry tab is opened and where would I insert it? I've tried all morning with no success so far! Thanks, Nick, I'm copy pasting this post this time round, I don't trust this website now Hi there, Im a total newbie and learning html and javascript as I go along, so any help you can give is greatly appreciated! It is possible to perform a find in page search that looks at a specific link, opens the page in a new window and finds the text within that document?? Basically I regularly use an html page in work that has a list of people and their telephone numbers. I want to be able to type in a searchbox on my main page and it open the target page and find the name I am looking for? Is this possible or can you only Find In Page on the same page or another frame? Tearing my hair out........ Thanks Glen Evening folks I'm -very- green when it comes to Javascript, but I'm working my way up. The problem right now I'm running in to now is when trying to implement a website function that allows two buttons (previous, and next) to do their respective tasks. I can get the script to go forward and back, however when I jump to another page in the frame (this is all through iframes), when clicking either button, it will take me to the last page I had stopped on. A little hard to explain, but maybe seeing the code will give you a better idea. <script type="text/javascript"> var pNum=0; var maxPage=10; function next() { pNum++; if (pNum > maxPage) pNum=10; document.getElementById("frame").src="page"+pNum+".htm"; } function prev() { pNum--; if (pNum < 0) pNum=0; document.getElementById("frame").src="page"+pNum+".htm"; } </script> It's nothing fancy, but it's apparently keeping the last page it was on in memory instead of resetting itself, so when I go back to the start page it starts on page 0 and goes to page 10; right now I can stop on page 5, click a link to go back to the starting default page, and when using the 'next page' button it will start on 6 and go from there. Any help or advice would be appreciated. HI I have tow page and the first page open a new window with javascript(by using window.open).Now I want to call a javascript function that is in the first page from the second page and for that i use parent.function_name but it doesn't work.How can do so? thanks <frameset rows="30%,70%> <frame src="page1.html" name="name1" frameborder="0"></frame> <frame src="page2.html" name="name2" frameborder="0"></frame> </frameset> in above code I used page1.html & page2.html as frame. Both include same javascript file having two function name fun1() & fun2(). as both are separate frame both have there own copy function page1.html fun1() fun2() page2.html fun1() fun2() I call fun2() from page2.html and inside that function I want to call page1.html's fun1(). fun1() in page1.html and fun1() in page2.html both return different result because of there global variables. Is there any way to call fun1()-page1.html from the fun2()-page2.html? Hi guys, i have a code where if you press on a word some words disappear and new ones appear and then when you press on the word again everything goes back to normal. I am trying to get it so that after the first click if i press back it should go back to normal instead of having to press the word again but all i am getting at the moment when i press back is the the page with the changed text. Hi, The point is to have a PHP code on the same page as a javascript calling the PHP function. I am able to make this work when the PHP code is on an external file. But when all but XSL are on the same page, it won't do what it should. How to make this work? The PHP is correct as it is by its self. And so is the javascript as it is for calling other PHP code. The combination of these two in this case just won't work. PHP and Javascript: [CODE] <html ><head><title>Untitled 1</title></head> <body> <?php function dateToDayOfWeek($xmlDate, $useFormat = 'l') { $rd = 'Unknown'; if (count($xmlDate) == 1) { $element = $xmlDate[0]; if ($element instanceof DOMElement) { $rd = date($useFormat, strtotime($element->nodeValue)); } } return $rd; } function axasal(){ date_default_timezone_set('UTC'); $xslDoc = new DOMDocument(); $xslDoc->load("xslfile.xsl"); // Here comes the xsl file name. $xmlDoc = new DOMDocument(); $xmlDoc->load("http://free.worldweatheronline.com/feed/weather.ashx?q=milan,italy&format=xml&num_of_days=5&key=af8b2fc417222733111712"); $proc = new XSLTProcessor(); $proc->registerPHPFunctions('dateToDayOfWeek'); $proc->importStylesheet($xslDoc); echo $proc->transformToXML($xmlDoc); } ?> <script type="text/javascript"> function call_php(){ document.getElementById("place").innerHTML="<?php echo axasal(); ?>"; } </script> <form name = "form"> <input type = "button" name = "aaa" id = "aaa" value = "Click me" onclick = "call_php()" /> </form> <div id="place"></div> </body></html> [CODE] XSL: [CODE] <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlnshp="http://php.net/xsl"> <xsl:template match="data"> <html> <head><title></title></head> <body> <table> <tr> <xsl:apply-templates select="./weather" /> </tr> </table> </body> </html> </xsl:template> <xsl:template match="weather"> <td style="width: 97px"> <p><xsl:value-of select="php:function('dateToDayOfWeek', date)" /></p> <p><xsl:apply-templates select="./weatherIconUrl" /></p> </td> </xsl:template> <xsl:template match="weatherIconUrl"> <img> <xsl:attribute name="src"> <xsl:value-of select="." /> </xsl:attribute> </img> </xsl:template> </xsl:stylesheet> [CODE] The smiley face on the second line of the last code is ':' and 'p'. hi, I have a google map which shows a car moving along a line that it reads from xml. This is the code that moves the map and the car image: Code: // Returns the bearing in radians between two points. function bearing( from, to ) { // See T. Vincenty, Survey Review, 23, No 176, p 88-93,1975. // Convert to radians. var lat1 = from.latRadians(); var lon1 = from.lngRadians(); var lat2 = to.latRadians(); var lon2 = to.lngRadians(); // Compute the angle. var angle = - Math.atan2( Math.sin( lon1 - lon2 ) * Math.cos( lat2 ), Math.cos( lat1 ) * Math.sin( lat2 ) - Math.sin( lat1 ) * Math.cos( lat2 ) * Math.cos( lon1 - lon2 ) ); if ( angle < 0.0 ) angle += Math.PI * 2.0; if (angle == 0) {crash;} return angle; } function plotcar() { var cosa = Math.cos(angle); var sina = Math.sin(angle); canvas.clearRect(0,0,32,32); canvas.save(); canvas.rotate(angle); canvas.translate(16*sina+16*cosa,16*cosa-16*sina); canvas.drawImage(img,-16,-16); canvas.restore(); } //=============== animation functions ====================== function animate(d) { if (d>eol) { return; } var p = poly.GetPointAtDistance(d); if (k++>=180/step) { map.panTo(p); k=0; } map.panTo(p); marker.setPoint(p); if (supportsCanvas) { if (poly.GetIndexAtDistance(d)>lastVertex) { lastVertex = poly.GetIndexAtDistance(d); if (lastVertex == poly.getVertexCount()) { lastVertex -= 1; } while (poly.getVertex(lastVertex-2).equals(poly.getVertex(lastVertex-1))) { lastVertex-=1; } angle = bearing(poly.getVertex(lastVertex-2),poly.getVertex(lastVertex-1) ); plotcar(); } } setTimeout("animate("+(d+step)+")", tick); } function startAnimation() { eol=poly.Distance(); map.setCenter(poly.getVertex(0),16); map.addOverlay(new GMarker(poly.getVertex(0),G_START_ICON)); map.addOverlay(new GMarker(poly.getVertex(poly.getVertexCount()-1),G_END_ICON)); if (supportsCanvas) { marker = new ELabel(poly.getVertex(0), '<canvas id="carcanvas" width="32" height="32"><\/canvas>',null,new GSize(-16,16)); map.addOverlay(marker); canvas = document.getElementById("carcanvas").getContext('2d'); var p0 = poly.getVertex(0); var p1 = poly.getVertex(1); angle = bearing(p1,p0); plotcar(); } else { marker = new GMarker(poly.getVertex(0),{icon:car}); map.addOverlay(marker); } poly2 = new GPolyline([poly.getVertex(0), poly.getVertex(1), poly.getVertex(2)], 0,0); // map.addOverlay(poly2); setTimeout("animate(0)",2000); // Allow time for the initial map display } It works fine as you can see here but the problem is that if the user clicks the button again without reloading the page, the map moves but the car remains at its last point. From what I can figure out, this means that the startAnimation() function has restarted but the animate(d) function has not restarted. but trying to call the animate(d) function from the button, where the startAnimation() gets called, he Code: <input type="button" onclick="startAnimation();return false;" value="show bus route 1"> results in an error that d is not defined. is there some way of resetting the animate(d) function when the startAnimation() function gets called, so everything goes back to the start? Or is there some other way of "refreshing" everything without reloading the page? thanks in advance. I'm new to javascript and have come across what I'm sure its a really easy problem to solve. I want a page with a hyperlink that passes a variable to another 'pop-up' page (in this case a name, its just an example) and new pop-up page prints a message followed by the variable thats passed. Here is the code as it is right now Code: <html> <head> <script language="javascript" type="text/javascript"> function popitup(a) { var reply = 'a'; newwindow=window.open('','name','height=200,width=150'); var tmp = newwindow.document; tmp.write('<html><head><title>popup</title>'); tmp.write('</head><body><p>"Hello there" + reply </p>'); tmp.write('<p><a href="javascript:self.close()">close</a> the popup.</p>'); tmp.write('</body></html>'); tmp.close(); } </script> </head> <body> <a href="testpopup.html" onclick="popitup('Toby')" >Link to popup</a> </body> </html> In short, I just want the pop-up page to print 'Hello there Toby' or whatever name I choose to pass across. Any help much appreciated!! The 'testpopup.html' url is just the initial webpage. I've searched everywhere for help on how to do this... I have a website for tanning salon services. Salon A's page has links for 4 possible equipment choices -[I] (diamond, platinum, gold, bronze levels) on the Sunbeds page. Sunbeds page has 2 iFrames, top and bottom, that are changed by 4 functions - changediamond(), changebronze(), etc. based on the selection. I need to be able to click a link on the Salon page that will take me to the corresponding function on the Sunbeds page... Here's what I have so far: Salon A page Code: <a href="sunbeds.htm?javascript:changediamond()"><img src="images/nr_diam_sm2.jpg" alt="Diamond Level Sunbeds" /></a> (thru) <a href="sunbeds.htm?javascript:changebronze()"><img src="images/nr_brnz_sm2.jpg" alt="Bronze Level Sunbeds" /></a> Sunbeds page Code: <SCRIPT language="JavaScript"> function changediamond() { parent.FRAME1.location="sb_top_ct1.htm"; parent.FRAME2.location="sb_bot_ct1.htm"; } (thru) function changebronze() { parent.FRAME1.location="sb_top_ct4.htm"; parent.FRAME2.location="sb_bot_ct4.htm"; } </script> . .. ... .. . <a href="javascript:changediamond()"><img src="images/diamond_sm2.jpg" alt="Diamond Level Sunbeds" /></a> (thru) <a href="javascript:changebronze()"><img src="images/bronze_sm2.jpg" alt="Bronze Level Sunbeds" /></a> The links take me to the correct page but not the function. Once I'm there I can select the functions and the iFrame change works great. I'm just at a loss for passing along the data string ie sunbeds.htm?javascript"changediamond() I would certainly appreciate any help and advice you could share. I'm sure it's pretty simple but for a JS newbie, it's frustrating! this is my html page.. Code: <html> <head> <script type="text/javascript" language="JavaScript"> function general_formats() { window.open('http://www.test.com/general_formats.php'); } </script> </head> <body> <a href="general_formats.php"><onclick="general_formats(); return false">General Formats</a> </body> </html> When i click ' general Formats ' , a window is opened , i dont need that . What i need is , when i click the link , it should direct to general_fomats.php.. please help me to solve it . .any help will be appreciated . hello .. I want ask how can I call function located in java script file from html file . also I have many java scripts file connected to my html file . thanks.. what's the fastest or easiest way to get all comment nodes into an Array? the solution only needs to work in ie8/w3 if that helps. |