JavaScript - Hide Images By Their Type (already Found Script Just Need It To Be Modified)
ok i have already found a script to hide a certin file type here it is:
Code: x=getAttribute('src')x=x.substring(0, x.indexOf('.jpg')); I don't know javascript so can someone please explain what that does to me and please modify it so it will work with this Code: var displayStyle = (divIndex==selectedIndex || selectedIndex===true)?'inline':'none'; document.getElementById('game_'+divIndex).style.display = displayStyle; basically i want to 1. change the script so it finds .jpg and .JPG 2. use the script in the second script below to basically hide the objects with that extension you can use the second script or make a new one if you want... 3. make it so i can make a link go to javascript:functiontocall() and thats it Thanks in advance and please help it shouldn't take more then a few minutes. Similar TutorialsHi there, I am having a hard time trying to understand this: The script I am using does not work if I write doctype as follows: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> But it does when removing the link: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" > However when I remove the link from the doc type, in IE my selected menu is unaligned; Here is the link. Have you got an idea about why it does not work with the full doc type? Thanks a lot for having a look; Hey guys, I'm new to the forums, so if i post anything wrong let me know. I'm trying to use links to hide all the images, and show just ones from a certain category. I've used the img name attribute to group them and tried to do a function that shows only one img. here's the script... <script language="javascript"> function showone(x) { document.getElementByName('a').style.display='none'; document.getElementByName('b').style.display='none'; document.getElementByName('c').style.display='none'; document.getElementByName(x).style.display='block'; } </script> and the code... <a href="#" onClick="showone('a'); ">show CAT. A</a><br> <a href="#" onClick="showone('b'); ">show CAT. B</a><br> <a href="#" onClick="showone('c'); ">show CAT. C</a><br> <a href="#">show all cats</a><br> <br> <img name="a" src="imgs/a1.jpg" /><br> <img name="b" src="imgs/b1.jpg" /><br> <img name="a" src="imgs/a2.jpg" /><br> <img name="a" src="imgs/a3.jpg" /><br> <img name="b" src="imgs/b2.jpg" /><br> <img name="c" src="imgs/c1.jpg" /> Here's what it looks like... http://mattfalcone.com/tests/showhide.html except the links don't work like they should, and I can't figure out why. I'm an idiot with javascript, so if feel free to make fun of me, and if anyone knows how to get this simple function to work, please let me know and I'de appreciate it. Hey everyone I just signed up to this forum. I have been doing a cert IV in Networking IT and part of my course involves javascript. Its all pretty simple, but we dont really have a teacher who I can ask questions. Im have a dead line tonight for a heap of work and I just keep running into so many problems. They are all pretty simple, but I just am at the end of my thread (no pun intended). At the moment Im just working on a box form, and I keep getting object expected errors in relation to my onClick and undefined with my elements. Code: <head> <meta name="author" content= "5h!fTyLiV3z" /> <title>Pay Rate Calculater</title> <SCRIPT LANGUAGE="JavaScript"> function calulatePay() { var elements; var rate = eval(document.payForm.elements[0].value); var hours = eval(document.payForm.elements[1].value); var prod = rate * hours; if (isNaN(element[counter].value) || (element[counter].value == "") ) { if (hours >= 20) { alert("You earned $" + (prod+(hours*2)) + " in " + hours + " hours.") } else { alert("You earned $" + prod + " in " + hours + " hours.") } } else { alert ("Enter numbers please"); } } </SCRIPT> </head> <body> <FORM onSubmit="" NAME="payForm"> <CENTER> <TABLE ALIGN="CENTER" BGCOLOR="#888888" BORDER="3" CELLPADDING="5"> <TR> <TD BGCOLOR="#004080"> <FONT COLOR="#ffffff" FACE="Arial"><B>Calculate My Weekly Pay</B></FONT> </TD> </TR> <TR> <TD> <CENTER> $ <INPUT TYPE="number" NAME="rate" SIZE="11" MAXLENGTH="8" VALUE="Enter pay rate"> : <INPUT TYPE="number" NAME="hours" SIZE="16" MAXLENGTH="8" VALUE="Enter hours worked"> <INPUT TYPE="button" VALUE="Calculate" onClick='calulatePay()'> </CENTER> </TD> </TR> </TABLE> </CENTER> </FORM> </body> I know its all a bit sloppy, but Im just trying to rush though so much work... Any help would be great. If everyone is active tonight I probably will be. Normally I dont have this many problems, but I guess its just exam pressure... Cheers 5hifty I apologize if I am posting this in the wrong section. I am looking for a code or script for a certain type of game but I can't even figure out what this type of game would be called. The game I am talking about is called "cryptopix" at tanga.com. I would really like to implement something like that on my website that members could create and participate in. If anyone can help point me in the right direction I would be forever grateful. I would assume it's a java script.
I am trying to write a Java Script code, that will calculate hours worked in a day. whenever I try to test the code I get NA in the answer field. Thanks for your help Jason Code: <html> <head> <script type="text/javascript"> function calc(nForm){ var inHour = nForm.inHr; var inMinutes = nForm.inMin; var lunchOutHour = nForm.lunchOutHr; var lunchOutMinutes = nForm.lunchOutMin; var lunchInHour = nForm.lunchInHr; var lunchInMinutes = nForm.lunchInMin; var outHour = nForm.outHr; var outMinutes = nForm.outMin; var linearInTime = 60*(inHour)+(inMinutes); var linearLunchOutTime = 60*(lunchOutHour)+(lunchOutMinutes); var linearLunchInTime = 60*(lunchInHour)+(lunchInMinutes); var linearOutTime = 60*(outHour)+(outMinutes); if (linearLunchOutTime < linearInTime || linearLunchInTime < linearLunchOutTime || linearOutTime < linearLunchInTime){alert('Invalid Information');return false} var workDay = linearOutTime-linearInTime; var lunchPeriod = linearLunchInTime-linearLunchOutTime; var linearMinutesWorked = workDay-lunchPeriod; var hoursWorked = parseInt(linearMinutesWorked/60); var minutesWorked = linearMinutesWorked-(hoursWorked*60) if (hoursWorked < 10){hoursWorked = "0"+hoursWorked} if (minutesWorked < 10){minutesWorked = "0"+minutesWorked} nForm.timeWorked.value = hoursWorked+":"+minutesWorked; } </script> </head> <body> <form name='timeSheet'> Clock In: <label> <input name="inHr" type="text" id="inHr" size="10"> </label>   <label> <input name="inMin" type="text" id="inMin" size="10"> </label> <br> Lunch Out: <label> <input name="lunchOutHr" type="text" id="lunchOutHr" size="10"> </label>   <label></label> <input name="lunchOutMin" type="text" id="lunchOutMin" size="10"> <br> Lunch In: <label> <input name="lunchInHr" type="text" id="lunchInHr" size="10"> </label>   <label> <input name="lunchInMin" type="text" id="lunchInMin" size="10"> </label> <br> Clock Out: <label> <input name="outHr" type="text" id="outHr" size="10"> </label>   <label> <input name="outMin" type="text" id="outMin" size="10"> </label> <br> <br> Time Worked: <input type='text' name='timeWorked' size='5' readonly> <br><br> <input type='button' value="Calculate" onClick="calc(this.form)"> </form> </body> </html> Code: <script type="text/javascript"> function toggleVisibility4(controlId) { var z = document.forms["frm_sms"]["phone"].value; var minimumnum = 10; var control = document.getElementById(controlId); if (z.length <= minimumnum) { control.style.visibility = "visible"; } else { control.style.visibility = "hidden"; } </script> im not sure where im going wrong i am calling this script from a " onkeyup="toggleVisibility4('arrow')" " the arrow is a div i am wanting to hide when the input field "phone" on a form id of "frm_sms" has more than 10 characters any ideas guys Hey everyone. I have a simple hide/show script that is doing what I want, but I was wondering if there is an easier way around having to specify show and hide requirements "onclick" each time. Here is what I've got: Javascript: Code: <script type="text/javascript"> function show(boxid) { document.getElementById(boxid).style.display="block"; } function hide(boxid) { document.getElementById(boxid).style.display="none"; } </script> HTML: Code: <body onload="hide('homePoster1'); hide('homePoster2'); hide('homePoster3'); hide('homePoster4'); hide('filmDesc1'); hide('filmDesc2'); hide('filmDesc3'); hide('filmDesc4'); "> <div id="homePoster1"><img src="img/posters/babystory.gif" width="419" height="419" /></div> <div id="homePoster2"><img src="img/posters/converse.gif" width="419" height="419" /></div> <div id="homePoster3"><img src="img/posters/cookingchannel.jpg" width="419" height="419" /></div> <div id="homePoster4"><img src="img/posters/culturesofresistance.jpg" width="419" height="419" /></div> <div class="filmDescAll"> <h2>Film 1 title</h2> <div id = "filmDesc1">Film 1 description</div> <div class="more"><a href="#" onclick="show('filmDesc1'); hide('filmDesc2'); hide('filmDesc3'); hide('filmDesc4'); show('homePoster1'); hide('homePoster2'); hide('homePoster3'); hide('homePoster4');">+ more info</a></div> </div> <div class="filmDescAll"> <h2>Film 2 title</h2> <div id="filmDesc2">Film 2 description</div> <div class="more"><a href="#" onclick="show('filmDesc2'); hide('filmDesc1'); hide('filmDesc3'); hide('filmDesc4'); show('homePoster2'); hide('homePoster1'); hide('homePoster3'); hide('homePoster4');">+ more info</a></div> </div> <div class="filmDescAll"> <h2>Film 3 title</h2> <div id="filmDesc3">Film 3 description</div> <div class="more"><a href="#" onclick="show('filmDesc3'); hide('filmDesc1'); hide('filmDesc2'); hide('filmDesc4'); show('homePoster3'); hide('homePoster1'); hide('homePoster2'); hide('homePoster4');">+ more info</a></div> </div> <div class="filmDescAll"> <h2>Film 4 title</h2> <div id="filmDesc4">Film 4 description</div> <div class="more"><a href="#" onclick="show('filmDesc4'); hide('filmDesc1'); hide('filmDesc2'); hide('filmDesc3'); show('homePoster4'); hide('homePoster1'); hide('homePoster2'); hide('homePoster3');"class="more4">+ more info</a></div> </div> Hi, I'm trying to use the code from DHTMLGoodies' show/hide script, from he http://www.dhtmlgoodies.com/index.ht..._content_slide but I want to use it for two different classes in my HTML, as I have two sizes of header buttons (I have a taller button to cope with text that is too long to fit in one line, as it wraps around). I have created the CSS styles as given on the website, but I have made a second style, to display the taller button, but I would like to know how to make the javascript work with it. Currently I have: Code: /*********** DHTML_GOODIES SLIDING TEXT START ***********/ div#thincolumn .dhtmlgoodies_question, div#thincolumn .dhtmlgoodies_question_big {background: url(images/thincolblue.jpg) no-repeat top left;height: 32px;color:#FFFFFF;padding:8px 14px 0 14px;font:bold 1.1em Arial, sans-serif;overflow:hidden;cursor:pointer;} div#thincolumn .dhtmlgoodies_question_big {background: url(images/thincolblue2.jpg) no-repeat top left;height:50px;} div#thincolumn .dhtmlgoodies_answer{ /* Parent box of slide down content */ /* Start layout CSS */ width:150px; /* End layout CSS */ visibility:hidden; height:0px; overflow:hidden; position:relative; } div#thincolumn .dhtmlgoodies_answer_content, .dhtmlgoodies_answer_content_big { /* Content that is slided down */ padding:1px; font-size:1em; position:relative; } /*********** DHTML_GOODIES SLIDING TEXT END ***********/ (div#thincolumn is the column that I place the buttons in). I added a new style, .dhtmlgoodies_question_big, to style the taller buttons, but I don't know how to change the Javascript so that it works on these divs as well as the normal, dhtmlgoodies_question divs. Near the end of the Javascript it says: Code: if(divs[no].className=='dhtmlgoodies_question'){ Is it possible to put an "or" in there and have something like Code: if(divs[no].className=='dhtmlgoodies_question')or(divs[no].className=='dhtmlgoodies_question_big'){ Please forgive my ignorance, I am fine with CSS and HTML, but I have never used Javascript before, and searching for "Javascript" and "or" on Google obviously didn't produce the result I was looking for! I don't even know if it's possible to use "or" in Javascript. I have tried duplicated the entire Javascript like this: Code: <script type="text/javascript"> /************************************************************************************************************ (C) www.dhtmlgoodies.com, November 2005 This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website. Terms of use: You are free to use this script as long as the copyright message is kept intact. However, you may not redistribute, sell or repost it without our permission. Thank you! www.dhtmlgoodies.com Alf Magne Kalleland ************************************************************************************************************/ var dhtmlgoodies_slideSpeed = 60; // Higher value = faster var dhtmlgoodies_timer = 10; // Lower value = faster var objectIdToSlideDown = false; var dhtmlgoodies_activeId = false; var dhtmlgoodies_slideInProgress = false; function showHideContent(e,inputId) { if(dhtmlgoodies_slideInProgress)return; dhtmlgoodies_slideInProgress = true; if(!inputId)inputId = this.id; inputId = inputId + ''; var numericId = inputId.replace(/[^0-9]/g,''); var answerDiv = document.getElementById('dhtmlgoodies_a' + numericId); objectIdToSlideDown = false; if(!answerDiv.style.display || answerDiv.style.display=='none'){ if(dhtmlgoodies_activeId && dhtmlgoodies_activeId!=numericId){ objectIdToSlideDown = numericId; slideContent(dhtmlgoodies_activeId,(dhtmlgoodies_slideSpeed*-1)); }else{ answerDiv.style.display='block'; answerDiv.style.visibility = 'visible'; slideContent(numericId,dhtmlgoodies_slideSpeed); } }else{ slideContent(numericId,(dhtmlgoodies_slideSpeed*-1)); dhtmlgoodies_activeId = false; } } function slideContent(inputId,direction) { var obj =document.getElementById('dhtmlgoodies_a' + inputId); var contentObj = document.getElementById('dhtmlgoodies_ac' + inputId); height = obj.clientHeight; if(height==0)height = obj.offsetHeight; height = height + direction; rerunFunction = true; if(height>contentObj.offsetHeight){ height = contentObj.offsetHeight; rerunFunction = false; } if(height<=1){ height = 1; rerunFunction = false; } obj.style.height = height + 'px'; var topPos = height - contentObj.offsetHeight; if(topPos>0)topPos=0; contentObj.style.top = topPos + 'px'; if(rerunFunction){ setTimeout('slideContent(' + inputId + ',' + direction + ')',dhtmlgoodies_timer); }else{ if(height<=1){ obj.style.display='none'; if(objectIdToSlideDown && objectIdToSlideDown!=inputId){ document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.display='block'; document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.visibility='visible'; slideContent(objectIdToSlideDown,dhtmlgoodies_slideSpeed); }else{ dhtmlgoodies_slideInProgress = false; } }else{ dhtmlgoodies_activeId = inputId; dhtmlgoodies_slideInProgress = false; } } } function initShowHideDivs() { var divs = document.getElementsByTagName('DIV'); var divCounter = 1; for(var no=0;no<divs.length;no++){ if(divs[no].className=='dhtmlgoodies_question'){ divs[no].onclick = showHideContent; divs[no].id = 'dhtmlgoodies_q'+divCounter; var answer = divs[no].nextSibling; while(answer && answer.tagName!='DIV'){ answer = answer.nextSibling; } answer.id = 'dhtmlgoodies_a'+divCounter; contentDiv = answer.getElementsByTagName('DIV')[0]; contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px'; contentDiv.className='dhtmlgoodies_answer_content'; contentDiv.id = 'dhtmlgoodies_ac' + divCounter; answer.style.display='none'; answer.style.height='1px'; divCounter++; } } } window.onload = initShowHideDivs; </script> <!-- END OF SLIDING TEXT JAVASCRIPT --> and Code: <script type="text/javascript"> /************************************************************************************************************ (C) www.dhtmlgoodies.com, November 2005 This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website. Terms of use: You are free to use this script as long as the copyright message is kept intact. However, you may not redistribute, sell or repost it without our permission. Thank you! www.dhtmlgoodies.com Alf Magne Kalleland ************************************************************************************************************/ var dhtmlgoodies_slideSpeed = 60; // Higher value = faster var dhtmlgoodies_timer = 10; // Lower value = faster var objectIdToSlideDown = false; var dhtmlgoodies_activeId = false; var dhtmlgoodies_slideInProgress = false; function showHideContent(e,inputId) { if(dhtmlgoodies_slideInProgress)return; dhtmlgoodies_slideInProgress = true; if(!inputId)inputId = this.id; inputId = inputId + ''; var numericId = inputId.replace(/[^0-9]/g,''); var answerDiv = document.getElementById('dhtmlgoodies_a' + numericId); objectIdToSlideDown = false; if(!answerDiv.style.display || answerDiv.style.display=='none'){ if(dhtmlgoodies_activeId && dhtmlgoodies_activeId!=numericId){ objectIdToSlideDown = numericId; slideContent(dhtmlgoodies_activeId,(dhtmlgoodies_slideSpeed*-1)); }else{ answerDiv.style.display='block'; answerDiv.style.visibility = 'visible'; slideContent(numericId,dhtmlgoodies_slideSpeed); } }else{ slideContent(numericId,(dhtmlgoodies_slideSpeed*-1)); dhtmlgoodies_activeId = false; } } function slideContent(inputId,direction) { var obj =document.getElementById('dhtmlgoodies_a' + inputId); var contentObj = document.getElementById('dhtmlgoodies_ac' + inputId); height = obj.clientHeight; if(height==0)height = obj.offsetHeight; height = height + direction; rerunFunction = true; if(height>contentObj.offsetHeight){ height = contentObj.offsetHeight; rerunFunction = false; } if(height<=1){ height = 1; rerunFunction = false; } obj.style.height = height + 'px'; var topPos = height - contentObj.offsetHeight; if(topPos>0)topPos=0; contentObj.style.top = topPos + 'px'; if(rerunFunction){ setTimeout('slideContent(' + inputId + ',' + direction + ')',dhtmlgoodies_timer); }else{ if(height<=1){ obj.style.display='none'; if(objectIdToSlideDown && objectIdToSlideDown!=inputId){ document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.display='block'; document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.visibility='visible'; slideContent(objectIdToSlideDown,dhtmlgoodies_slideSpeed); }else{ dhtmlgoodies_slideInProgress = false; } }else{ dhtmlgoodies_activeId = inputId; dhtmlgoodies_slideInProgress = false; } } } function initShowHideDivs() { var divs = document.getElementsByTagName('DIV'); var divCounter = 1; for(var no=0;no<divs.length;no++){ if(divs[no].className=='dhtmlgoodies_question_big'){ divs[no].onclick = showHideContent; divs[no].id = 'dhtmlgoodies_q'+divCounter; var answer = divs[no].nextSibling; while(answer && answer.tagName!='DIV'){ answer = answer.nextSibling; } answer.id = 'dhtmlgoodies_a'+divCounter; contentDiv = answer.getElementsByTagName('DIV')[0]; contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px'; contentDiv.className='dhtmlgoodies_answer_content_big'; contentDiv.id = 'dhtmlgoodies_ac' + divCounter; answer.style.display='none'; answer.style.height='1px'; divCounter++; } } } window.onload = initShowHideDivs; </script> <!-- END OF SLIDING TEXT JAVASCRIPT --> but now it only works for the taller buttons (which the second piece of Javascript refer to). I think it might be possible to just use one instance of the original code, and some "or" operators, but I'm not sure. Any help would be very much appreciated. Im using the following script: Code: <script type="text/javascript"> function unhide(hiddentext) { var item = document.getElementById(hiddentext); if (item) { item.className=(item.className=='hidden')?'unhidden':'hidden'; } } </script> <style type="text/css"> .unhidden { display: block; } .hidden { display: none; } </style> to hide and unhide a block of text on my page, using onclick events. the problem is its not allowing me to use it multiple times in a page. when i use a second instance of it, both stop working. the above demonstrated script is working with the following elements: middle (approx) of page: Code: <td class="desc_cell"><strong>Download Station</strong><br /> 17" Macbook Pro<br /><a href="javascript:unhide('itemlist');" onclick="changeText(this,'Hide Item List');" id="text1link"]Old Text>Click Here For Full Item List</a><div id="hiddentext" class="hidden">list of items goes herelist of items goes herelist of items goes herelist of items goes herelist of items goes herelist of items goes herelist of items goes herelist of items goes herelist of items goes herelist of items goes herelist of items goes herelist of items goes herelist of items goes herelist of items goes here</div> </td> bottom of page: [code]<p align="center" style="citylist">Allen Park MI, Anchor Bay Gardens MI, Anchor Bay Harbor MI, Anchor Bay Shores MI, Andersonville MI,<a href="javascript:unhide('hiddentext');" onclick="changeText(this,' View Less...');" id="text1link"]Old Text>View More...</a></p><div id="hiddentext" class="hidden">Armada MI, Auburn Heights MI, Auburn Hills MI, Austin Corneorth Farmington MI, Northville MI, Norton MI, Novi MI, Oak MI, Oak Grove MI, Oak Park MI, Oakley Park MI, Oakwood MI, Orchard Lake MI, Ortonville MI, Oxbow MI, Oxford MI, Perry Lake Heights MI, Pleasant Ridge MI, Plymouth MI, Point Lakeview MI, Pontiac MI, Preston Coom MI, Wolcott Mills MI, Wolverine Lake MI, Wood Creek Farms MI, Woodhaven MI, Wyandotte MI, Yates MI, and many more!</div> I have a form that was created in Adobe Professional. I have hidden the toolbars on initial view of the form, however, the people using the form have discovered how to un-hide them. Is there any Java Script that I can add to the document that will disable certain menu commands (i.e. "Attach to E-mail")?
Hi, I am new to javascript so any help would be much appreciated. I found the following script online to show/hide a login div. <script language="JavaScript" type="text/javascript"> function login(showhide){ if(showhide == "show"){ document.getElementById('popupbox').style.visibility="visible"; }else if(showhide == "hide"){ document.getElementById('popupbox').style.visibility="hidden"; } } </script> It works really well but I have other div I would also like to show/hide. Is it possible to have a variable in the function that I could pass the name of the div to show/hide. I have a ul list that I am using for a navigation menu and I would like to be able to click on items in the list to show different div's. I assume this is possible, so could someone please give me an indication of how to do it as I have been trying for a few days now and no joy. Thanks, James Helloo Im new to javascript.. I need help badly... here are two tabless. 1. information of a friend. 2nd table i get when i click da image (ADD ANOTHER FRIEND) but, on validation and submission.. the second table is not showing upp... When i once click ADD FRIEND.. i want the table to show up on reload and validation.... Thanks Here is my code <? if (isset($_POST['submit'])) { if (!$frndname) { $frndname_error = 1; $problems=1; } if (!$frndcity) { $frndcity_error = 1; $problems=1; } ///doo db stuff insertion } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript"> function showTable() { var table = document.getElementById("myTable"); if (table) table.style.display = "block"; var div = document.getElementById("frndimg"); if(div) div.style.display = "none"; } </script> </head> <body> <form action="" method="POST" name="form1"> <?php if(!isset($_POST['submit']) or $problems) { ?> <table> <tr> <td colspan="2"> <table width="21%"> <tr> <td width="3%" align="left" valign="top"> </td> <td colspan="2"> <b class="referralheading"> YOUR FRIEND'S INFORMATION: </b> </td></tr> <tr> <td width="3%" align="left" valign="top"> </td> <td width="16%"><? if ($frndname_error) { echo ("<font color='#FF0000'>Name:</font>"); } else { echo ("Name:"); }?> <b><font color="#FF0000">*</font></b><br> <input type="text" name="frndname" id ="frndname" value="<?php echo $frndname; ?>" maxlength=45 size=25></td> <td width="81%" colspan="3">City: <b><font color="#FF0000">*</font></b><br><input type="text" id="frndcity" name="frndcity" value="<?php echo $frndcity; ?>" maxlength=45 size=25> </td> </tr> </table></td></tr> <tr> <td width="4%" align="left" valign="top"> </td> <td > <div style="float:left;cursorointer;"> <img src="images/referral_add_friend.jpg" width="190" height="28" onClick="showTable()" title="Click to add another friend" id="frndimg"> </div> </td></tr> <tr> <td colspan="2"> <table width="100%" id="myTable" style="display:none;"> <tr> <td width="4%" align="left" valign="top"> </td> <td colspan="2"> <b class="referralheading"> YOUR FRIEND'S INFORMATION: </b> </td></tr> <tr> <td width="4%" align="left" valign="top"> </td> <td width="53%"> NAme: <b><font color="#FF0000">*</font></b><br> <input type="text" name="frnd1name" id ="frnd1name" value="<?php echo $frnd1name; ?>" maxlength=45 size=25></td> <td width="47%" colspan="3">City: <b></b><br><input type="text" id="frnd1city" name="frnd1city" value="<?php echo $frnd1city; ?>" maxlength=45 size=25> </td> </tr> <tr> <td width="4%" align="left" valign="top"> </td> <td>Phone Number: <b></b><br> <input type="text" name="frnd1phone" id ="frnd1phone" value="<?php echo $frnd1phone; ?>" maxlength=45 size=25></td> <td colspan="3">Email: <br><input type="text" id="frnd1email" name="frnd1email" value="<?php echo $frnd1email; ?>" maxlength=45 size=25> </td> </tr> <tr><td> </td></tr> </table> </td></tr> <tr> <td><input type="image" src="images/submit_referral.jpg" height="30" width="173" border="0" alt="Submit Form" value="submit"></td></tr> <tr><td> </td><td align="center" class="referralheading"> Fields Marked With * Are Required</td></tr> </table> <? } ?> </form> </body> </html> Hello...I need to display the last modified date of each file on my webpage. There are a variety of files including, .doc, .pdf, .ppt, .zip, etc. I am able to get the last modified date to work, however I would like to know if it is possible to format the output of the date/time? I have the following code in the head of my html file: Code: <script type="text/javascript"> function getlastmod(what) { var http=new XMLHttpRequest() http.open('HEAD',what,false) http.send(null) if (http.status!=200) return undefined return http.getResponseHeader('Last-modified') } </script> In the body section, I have the following: Code: <ul> <li><a href="documents/OMB_Memo_Conferences_Sep_2011.pdf" target="_blank"> OMB Memo Conferences</a> <script type="text/javascript">document.write(getlastmod('documents/OMB_Memo_Conferences_Sep_2011.pdf'))</script> <br /></li> <li><a href="documents/NavOceano_Crb.doc" target="_blank">Nav Oceano CRB</a> <script type="text/javascript">document.write(getlastmod('documents/NavOceano_Crb.doc'))</script><br /> </ul> The output is: OMB Memo Conferences Fri, 11 May 2012 13:00:49 GMT Nav Oceano CRB Fri, 11 May 2012 13:00:38 GMT Is there any way to format the last modified date/time to display just the following: OMB Memo Conferences May 11, 2012 Nav Oceano CRB May 11, 2012 Any help would be appreciated. Thanks, Andy I feel a little stupid to ask this question but it has always been on my mind. <html> <head> <script type="text/javascript"> { var lastMod = new Date (document.lastModified); document.write ("<p>Document last modified "); document.write ((lastMod.getMonth() +1) + "-" + lastMod.getDate() + "-" + lastMod.getFullYear()); document.write ("<p>"); } </script> </head> </html> when i open in ie or ff it renders 2/25/11 (supposed to be 2/26/11) but when i use it in chrome or an html test is renders correctly. why? Hi, I am having some problems with this modified version of Lightbox. I had a programmer implement this into the site and then one day it just stopped working. I'm trying to fix it myself, with no success. To view the problem go to: http://www.uscgq.com/question/deck/2 and click the red flag icon. The lightbox opens, but only shows the "Loading" message. I have isolated the problem to somewhere in the Lightbox.js just don't know where or what it is. Any help is greatly appreciated! Code: /* Created By: Chris Campbell Website: http://particletree.com Date: 2/1/2006 Inspired by the lightbox implementation found at http://www.huddletogether.com/projects/lightbox/ */ /*-------------------------------GLOBAL VARIABLES------------------------------------*/ var detect = navigator.userAgent.toLowerCase(); var OS,browser,version,total,thestring; /*-----------------------------------------------------------------------------------------------*/ //Browser detect script origionally created by Peter Paul Koch at http://www.quirksmode.org/ function getBrowserInfo() { if (checkIt('konqueror')) { browser = "Konqueror"; OS = "Linux"; } else if (checkIt('safari')) browser = "Safari" else if (checkIt('omniweb')) browser = "OmniWeb" else if (checkIt('opera')) browser = "Opera" else if (checkIt('webtv')) browser = "WebTV"; else if (checkIt('icab')) browser = "iCab" else if (checkIt('msie')) browser = "Internet Explorer" else if (!checkIt('compatible')) { browser = "Netscape Navigator" version = detect.charAt(8); } else browser = "An unknown browser"; if (!version) version = detect.charAt(place + thestring.length); if (!OS) { if (checkIt('linux')) OS = "Linux"; else if (checkIt('x11')) OS = "Unix"; else if (checkIt('mac')) OS = "Mac" else if (checkIt('win')) OS = "Windows" else OS = "an unknown operating system"; } } function checkIt(string) { place = detect.indexOf(string) + 1; thestring = string; return place; } /*-----------------------------------------------------------------------------------------------*/ Event.observe(window, 'load', initialize, false); Event.observe(window, 'load', getBrowserInfo, false); Event.observe(window, 'unload', Event.unloadCache, false); var lightbox = Class.create(); lightbox.prototype = { yPos : 0, xPos : 0, initialize: function(ctrl) { this.content = ctrl.href; Event.observe(ctrl, 'click', this.activate.bindAsEventListener(this), false); ctrl.onclick = function(){return false;}; }, // Turn everything on - mainly the IE fixes activate: function(){ if (browser == 'Internet Explorer'){ this.getScroll(); this.prepareIE('100%', 'hidden'); this.setScroll(0,0); this.hideSelects('hidden'); } this.displayLightbox("block"); }, // Ie requires height to 100% and overflow hidden or else you can scroll down past the lightbox prepareIE: function(height, overflow){ bod = document.getElementsByTagName('body')[0]; bod.style.height = height; bod.style.overflow = overflow; htm = document.getElementsByTagName('html')[0]; htm.style.height = height; htm.style.overflow = overflow; }, // In IE, select elements hover on top of the lightbox hideSelects: function(visibility){ selects = document.getElementsByTagName('select'); for(i = 0; i < selects.length; i++) { selects[i].style.visibility = visibility; } }, // Taken from lightbox implementation found at http://www.huddletogether.com/projects/lightbox/ getScroll: function(){ if (self.pageYOffset) { this.yPos = self.pageYOffset; } else if (document.documentElement && document.documentElement.scrollTop){ this.yPos = document.documentElement.scrollTop; } else if (document.body) { this.yPos = document.body.scrollTop; } }, setScroll: function(x, y){ window.scrollTo(x, y); }, displayLightbox: function(display){ $('overlay').style.display = display; $('lightbox').style.display = display; if(display != 'none') this.loadInfo(); }, // Begin Ajax request based off of the href of the clicked linked loadInfo: function() { var myAjax = new Ajax.Request( this.content, {method: 'post', parameters: "", onComplete: this.processInfo.bindAsEventListener(this)} ); }, // Display Ajax response processInfo: function(response){ console.log('calling process info'); if($('lbHeader')) Element.remove($('lbHeader')); info = "<div id=\"lbHeader\"><a href=\"javascript: closeLightboxes();\">close</a> or hit ESC</div><div id='lbContent'>" + response.responseText + "</div>"; new Insertion.Before($('lbLoadMessage'), info) $('lightbox').className = "done"; this.actions(); }, // Search through new links within the lightbox, and attach click event actions: function(){ lbActions = document.getElementsByClassName('lbAction'); for(i = 0; i < lbActions.length; i++) { Event.observe(lbActions[i], 'click', this[lbActions[i].rel].bindAsEventListener(this), false); lbActions[i].onclick = function(){return false;}; } }, // Example of creating your own functionality once lightbox is initiated insert: function(e){ link = Event.element(e).parentNode; Element.remove($('lbContent')); var myAjax = new Ajax.Request( link.href, {method: 'post', parameters: "", onComplete: this.processInfo.bindAsEventListener(this)} ); }, // Example of creating your own functionality once lightbox is initiated deactivate: function(){ if($('lbHeader')) Element.remove($('lbHeader')); Element.remove($('lbContent')); if (browser == "Internet Explorer"){ this.setScroll(0,this.yPos); this.prepareIE("auto", "auto"); this.hideSelects("visible"); } this.displayLightbox("none"); } } /*-----------------------------------------------------------------------------------------------*/ // Onload, make all links that need to trigger a lightbox active function initialize(){ addLightboxMarkup(); lbox = document.getElementsByClassName('lbOn'); for(i = 0; i < lbox.length; i++) { valid = new lightbox(lbox[i]); } } // Add in markup necessary to make this work. Basically two divs: // Overlay holds the shadow // Lightbox is the centered square that the content is put into. function addLightboxMarkup() { bod = document.getElementsByTagName('body')[0]; overlay = document.createElement('div'); overlay.id = 'overlay'; lb = document.createElement('div'); lb.id = 'lightbox'; lb.className = 'loading'; lb.innerHTML = '<div id="lbLoadMessage">' + '<p>Loading</p>' + '</div>'; bod.appendChild(overlay); bod.appendChild(lb); } // Send AJAX Call function sendForm(url) { new Ajax.Updater('lbContent', url, { method: 'post', parameters: Form.serialize($('content_form'),true) }); } // Function to destroy lightbox elements function closeLightboxes() { if(lightbox.prototype) lightbox.prototype.displayLightbox('none'); if($('lbHeader')) Element.remove($('lbHeader')); if($('lbContent')) Element.remove($('lbContent')); } // Close the lightbox if ESC is pressed document.onkeypress=function(e){ var KeyID = (window.event) ? event.keyCode : e.keyCode; if(KeyID == 27) { closeLightboxes(); } } What I mean is that my <body> tag currently is like this: Code: <body class="page-course"> I would like to insert a pop-up contact form which requires the body tag to be like this: Code: <body onload="javascript:fg_hideform('fg_formContainer','fg_backgroundpopup');"> Not quite sure how to merge these - indeed can I merge them? Perhaps better to make the body class (top example) execute elsewhere? THANKS!! I have a personal academic website in which I made a small last modified JS. I used the last.modified string for windows of the following format: MM/DD/YYYY HH:MM:SS , the time being two hour indices, two minute indices and two second indices. I took substrings of the last.modified string and used an array of "month words" for the month substring, to make the display of it more aesthetically pleasing. When I checked my website on my Google phone, I realized that the last.modified string has a different format as follows: (Day, first three letters), DD (Month, first three letters) YYYY HH:MM:SS GMT , so all the relevant indices were offset, which messed up the script. Is there any way to gear this script to work for both windows computers and Google phones, creating two different cases one for phone and one for computer? Maybe even Macs and all smartphones in general? Or is there maybe an easier way to do this server-side? Thanks in advance! Hi, I have main html page called "ana.html" which seldomly updated and another page "yeniler.html" that showing latest added articles and often updated. What I want is, whenever "yeniler.html" modified the javascript in "ana.html" shows "Latest Update Date: xx.xx.xxxx". As you can see I don't want to show file modified date of "ana" in "ana" like so many scripts offer on the web , but in page "ana" modified date of "yeniler" I also want the date format like 8.18.2008 (without hour, minute, and name of the month) suggestions welcome !!
I have an xml file: http://greenandtheblue.com/weather/parks.xml I'd like to display on an html page the time this xml document was last modified. I've done this successfully with php, but I'm wondering if I can do this with Javascript? The file will be in the same directory as the website/html page. I've googled for a while now with no success. Thanks for any help, S |