JavaScript - Can't Figure Out Javascript Error
Need help with the Script below. I got my radio buttons working, however...the rest of my form/webpage now won't appear. Advice? Please.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><!-- InstanceBegin template="/Templates/2009-fs2-ochdes.dwt" codeOutsideHTMLIsLocked="false" --> <!--#include virtual="/global/admin/2009-fs2-site-configuration.shtml" --> <head> <!-- InstanceBeginEditable name="doctitle" --> <title></title> <!-- InstanceEndEditable --> <!--#include virtual="/global/ssi/2009-fs2-meta-details.shtml" --> <!--#include virtual="/global/ssi/2009-fs2-meta-standard.shtml" --> <!--#include virtual="/global/ssi/2009-fs2-meta-scripts.shtml" --> <!-- InstanceBeginEditable name="head" --> <script type="text/javascript"> if (window.addEventListener) window.addEventListener('load',init, true); else window.attachEvent('onload',init); function init() { inputs=document.forms.form1.getElementsByTagName('input'); for(i=0;i<inputs.length;i++) if(inputs[i].type.toLowerCase()=='radio') { thisOne = inputs[i]; radio_buttons.push(thisOne); thisOne.onclick=check_visibility; } fieldsets = document.forms.form1.getElementsByTagName('fieldset'); check_visibility(); } function check_visibility() { for(f=0;f<fieldsets.length;f++) { thisFieldset=fieldsets[f]; if(thisFieldset.id==root_fieldset)checkFieldsets.push(thisFieldset); else thisFieldset.style.display="none"; } do { checkFieldset=checkFieldsets.pop();//get an item to check if(typeof checkFieldset=='undefined') continue; inputs=checkFieldset.getElementsByTagName('input'); if(inputs.count==0) continue;//no inputs to check for(i=0;i<inputs.length;i++) { if(inputs[i].type.toLowerCase()!='radio') continue; thisRadio=inputs[i]; if(!thisRadio.checked) continue; //its a radio and its selected! dependants=visibility_dependancies[thisRadio.id]; if(typeof dependants=='undefined') continue; if(dependants.length==0) continue; for(d=0; d<dependants.length;d++) { newlyVisibleFieldset=document.getElementById(dependants[d]); checkFieldsets.push(newlyVisibleFieldset); newlyVisibleFieldset.style.display='block'; } } } while (checkFieldsets.length>0) } var radio_buttons = new Array(); var fieldsets = new Array(); var root_fieldset = 'Facility_Location_set'; var checkFieldsets = new Array(); var visibility_dependancies={ 'Facility_Location_BFR':new Array('BFR_type_set'), 'Facility_Location_BPAS':new Array('BPAS_type_set'), 'Facility_Location_CRES':new Array('CRES_type_set'), 'Facility_Location_GRLD':new Array('GRLD_type_set'), 'Facility_Location_LKMT':new Array('LKMT_type_set'), 'Facility_Location_PAU':new Array('PAU_type_set'), 'Facility_Location_RAC':new Array('RAC_type_set'), 'Facility_Location_SIS':new Array('SIS_type_set') }; </script> <style> fieldset{float:left; margin:0 2px;} label{padding-left:5px;} </style> <style type="text/css"> #TableBorder { border: thin solid #000; } </style> <!-- InstanceEndEditable --> </head> <body> <!--#include virtual="/global/ssi/2009-fs2-accessibility.shtml" --> <div id="page-wrapper"> <!--#include virtual="/global/ssi/2009-fs2-masthead.shtml" --> <!--#include virtual="/global/ssi/2009-fs2-spotlight-navigation.shtml" --> <div id="sidebar-wrapper" class="noprint"> <!--#include virtual="/global/ssi/2009-fs2-site-navigation.shtml" --> </div><!-- CLOSE sidebar-wrapper --> <div id="content-wrapper"> <!--#include virtual="/global/ssi/2009-fs2-contribute1.shtml" --> <!--#include virtual="/global/ssi/2009-fs2-breadcrumb.shtml" --> <!-- InstanceBeginEditable name="content" --> <h1>Report A Facility Maintenance Problem</h1> <!--#if expr="$QUERY_STRING = 'thankyou'" --> <h2>Thank You!</h2> <p>Thank you for reporting a Facility Maintenance Problem. </p> <!--#else --> <div id="contactus"> <form name="form1" id="form1" method="post" action="<!--#echo var='sitescripts' -->email-building-maint.php" /> <div id="emaildetails"> <input type="hidden" name="recipient_cc" value="cc" /> <input type="hidden" name="redirect" value="http://fsweb-ochdes.r6.fs.fed.us/eng/facilities/facility-maintenance-reporting/index.shtml?thankyou" /> <input type="hidden" name="required" value="Name,Phone_Number,email,recipient" /> <input type="hidden" name="subject" value="Facility Maintenance Problem Report" /> </div> <p><strong>* Fields with an asterisk are required</strong></p> <fieldset> <legend>Your Contact Information</legend> <dl> <dt><label for="Name">Your Name *</label></dt> <dd><input class="inputtext" type="text" id="Name" name="Name" /></dd> <dt><label for="Phone_Number">Your Telephone Number *</label></dt> <dd><input class="inputtext" type="text" name="Phone_Number" id="Phone_Number" /></dd> <dt><label for="email">Your Email Address *</label></dt> <dd><input class="inputtext" type="text" name="email" id="email" /></dd> <dt><label for="File_Location">Supporting Documents</label></dt> <p>If you have any supporting documents or shape files, please provide a file path to where it is stored on the network:</p> <dd><input class="inputtext" type="text" name="File_Location" id="File_Location" /></dd> </dl> <p><strong>Privacy Advisory:</strong> Your personal identifying information is being requested. We need this identifying information so that we can provide what you requested, and/or to respond to your comments. Generally, personal identifying information is destroyed after we fill your request. If you do not provide the requested personal information, we will be unable to respond directly to your request or comment.</p> </fieldset> <fieldset> <legend>Facility Site</legend> <p>Please provide the Facility Site:</p> <dl> <dt><label for="recipient">Facility Site*</label></dt> <dd><select class="inputselect" name="recipient" id="recipient"> <option value="" selected="selected">Select One...</option> <option value="bfr">Bend Fort Rock</option> <option value="bpas">Bend Pine Admin. Site</option> <option value="crescent">Crescent</option> <option value="GRLD">Crooked River National Grassland</option> <option value="LKMT">Lookout Mountain</option> <option value="PAU">Paulina</option> <option value="redmond">Redmond Air Center</option> <option value="sisters">Sisters</option> <option value="test">test</option> </select></dd> </dl> </fieldset> <fieldset id='Facility_Location_set'> <legend>Facility Location</legend> <div><input type='radio' name='Facility_Location' value='BFR' id='Facility_Location_BFR' /> Bend Fort Rock</div> <div><input type='radio' name='Facility_Location' value='BPAS' id='Facility_Location_BPAS' /> Bend Pine Admin. Site</div> <div><input type='radio' name='Facility_Location' value='CRES' id='Facility_Location_CRES' /> Crescent</div> <div><input type='radio' name='Facility_Location' value='GRLD' id='Facility_Location_GRLD' /> Crooked River National Grasslands</div> <div><input type='radio' name='Facility_Location' value='LKMT' id='Facility_Location_LKMT' /> Lookout Mountain</div> <div><input type='radio' name='Facility_Location' value='PAU' id='Facility_Location_PAU' /> Paulina</div> <div><input type='radio' name='Facility_Location' value='RAC' id='Facility_Location_RAC' /> Redmond Air Center</div> <div><input type='radio' name='Facility_Location' value='SIS' id='Facility_Location_SIS' /> Sisters</div> </fieldset> <fieldset id='BFR_type_set'> <legend>Facility Name</legend> <div><input type='radio' name='BFR_type' value='Fall River Guard Station' id='BFR_type_Fall River Guard Station' /> Fall River Guard Station</div> <div><input type='radio' name='BFR_type' value='Lavalands Vistor Center' id='BFR_type_Lavalands Vistor Center' /> Lavalands Vistor Center</div> <div><input type='radio' name='BFR_type' value='Lookout' id='BFR_type_Lookout' /> Lookout</div> <div><input type='radio' name='BFR_type' value='Paulina Lake GS' id='BFR_type_Paulina Lake GS' /> Paulina Lake GS</div> <div><input type='radio' name='BFR_type' value='Scott St.' id='BFR_type_Scott St.' /> Scott St.</div> <div><input type='radio' name='BFR_type' value='Snow Creek' id='BFR_type_Snow Creek' /> Snow Creek</div> <div>Campground Name <input type='text' name='random_text' value='' id='Campground Name' /></div> <div>Other <input type='text' name='random_text' value='' id='Other' /></div> </fieldset> <fieldset id='BPAS_type_set'> <legend>Facility Name</legend> <div><input type='radio' name='BPAS_type' value='Coolers' id='BPAS_type_Coolers' /> Coolers</div> <div><input type='radio' name='BPAS_type' value='Equipment Storage Bld.' id='BPAS_type_Equipment Storage Bld.' /> Equipment Storage Bld.</div> <div><input type='radio' name='BPAS_type' value='Lab' id='BPAS_type_Lab' /> Lab</div> <div><input type='radio' name='BPAS_type' value='New Office' id='BPAS_type_New Office' /> New Office</div> <div><input type='radio' name='BPAS_type' value='Packing Shed' id='BPAS_type_Packing Shed' /> Packing Shed</div> <div><input type='radio' name='BPAS_type' value='Shop' id='BPAS_type_Shop' /> Shop</div> </fieldset> <fieldset id='CRES_type_set'> <legend>Facility Name</legend> <div><input type='radio' name='CRES_type' value='Crescent Lake G.S.' id='CRES_type_Crescent Lake G.S.' /> Crescent Lake G.S.</div> <div><input type='radio' name='CRES_type' value='Lookout' id='CRES_type_Lookout' /> Lookout</div> <div><input type='radio' name='CRES_type' value='Office Compound' id='CRES_type_Office Compound' /> Office Compound</div> <div><input type='radio' name='CRES_type' value='Rosedale' id='CRES_type_Rosedale' /> Rosedale</div> <div>Campground Name <input type='text' name='random_text' value='' id='Campground Name' /></div> <div>Other <input type='text' name='random_text' value='' id='Other' /></div> </fieldset> <fieldset id='GRLD_type_set'> <legend>Facility Name</legend> <div><input type='radio' name='GRLD_type' value='Field Headquarters' id='GRLD_type_Field Headquarters' /> Field Headquarters</div> <div><input type='radio' name='GRLD_type' value='Lookout' id='GRLD_type_Lookout' /> Lookout</div> <div>Campground Name <input type='text' name='random_text' value='' id='Campground Name' /></div> <div>Other <input type='text' name='random_text' value='' id='Other' /></div> </fieldset> <fieldset id='LKMT_type_set'> <legend>Facility Name</legend> <div><input type='radio' name='LKMT_type' value='Dispatch' id='LKMT_type_Dispatch' /> Dispatch</div> <div><input type='radio' name='LKMT_type' value='Helibase' id='LKMT_type_Helibase' /> Helibase</div> <div><input type='radio' name='LKMT_type' value='Lamonta' id='LKMT_type_Lamonta' /> Lamonta</div> <div><input type='radio' name='LKMT_type' value='Lookout' id='LKMT_type_Lookout' /> Lookout</div> <div><input type='radio' name='LKMT_type' value='Ochoco R.S.' id='LKMT_type_Ochoco R.S.' /> Ochoco R.S.</div> <div><input type='radio' name='LKMT_type' value='Ranger Rental' id='LKMT_type_Ranger Rental' /> Ranger Rental</div> <div><input type='radio' name='LKMT_type' value='S.O.' id='LKMT_type_S.O.' /> S.O.</div> </fieldset> <fieldset id='PAU_type_set'> <legend>Facility Name</legend> <div><input type='radio' name='PAU_type' value='Cold Spring Rental' id='PAU_type_Cold Spring Rental' /> Cold Spring Rental</div> <div><input type='radio' name='PAU_type' value='Lookout' id='PAU_type_Lookout' /> Lookout</div> <div><input type='radio' name='PAU_type' value='Rager' id='PAU_type_Rager' /> Rager</div> <div>Campground Name <input type='text' name='random_text' value='' id='Campground Name' /></div> <div>Other <input type='text' name='random_text' value='' id='Other' /></div> </fieldset> <fieldset id='RAC_type_set'> <legend>Facility Name</legend> <div><input type='radio' name='RAC_type' value='Admin' id='RAC_type_Admin' /> Admin</div> <div><input type='radio' name='RAC_type' value='Air Tanker Base' id='RAC_type_Air Tanker Base' /> Air Tanker Base</div> <div><input type='radio' name='RAC_type' value='Barracks' id='RAC_type_Barracks' /> Barracks</div> <div><input type='radio' name='RAC_type' value='Cache' id='RAC_type_Cache' /> Cache</div> <div><input type='radio' name='RAC_type' value='Paraloft' id='RAC_type_Paraloft' /> Paraloft</div> <div><input type='radio' name='RAC_type' value='RAG' id='RAC_type_RAG' /> RAG</div> <div>Other <input type='text' name='random_text' value='' id='Other' /></div> </fieldset> <fieldset id='SIS_type_set'> <legend>Facility Name</legend> <div><input type='radio' name='SIS_type' value='Allingham' id='SIS_type_Allingham' /> Allingham</div> <div><input type='radio' name='SIS_type' value='Lookout' id='SIS_type_Lookout' /> Lookout</div> <div><input type='radio' name='SIS_type' value='Office Compound' id='SIS_type_Office Compound' /> Office Compound</div> <div><input type='radio' name='SIS_type' value='Portal' id='SIS_type_Portal' /> Portal</div> <div><input type='radio' name='SIS_type' value='Warehouse Compound' id='SIS_type_Warehouse Compound' /> Warehouse Compound</div> <div>Campground Name <input type='text' name='random_text' value='' id='Campground Name' /></div> <div>Other <input type='text' name='random_text' value='' id='Other' /></div> </fieldset> <fieldset> <legend>Maintenance Area</legend> <dl> <dt><label for="Type_of_Error">Problem that you would like to Report *</label></dt> <dd><select class="inputselect" name="Type_of_Error" id="Type_of_Error"> <option value="Select One">Select One ...</option> <option value="Doors/Locks/Gates = Access">Doors/Locks/Gates = Access</option> <option value="Fence">Fence</option> <option value="HVAC">HVAC</option> <option value="Lights">Lights</option> <option value="Restrooms">Restrooms</option> <option value="Windows/Blinds">Windows/Blinds</option> <option value="Other">Other</option> </select></dd> </dl> </fieldset> <fieldset> <legend>Miscellaneous Information</legend> <dl> <dt><label for="Additional_Information">Please Describe the Problem You are Reporting</label></dt> <dd><textarea class="inputtextarea" id="Additional_Information" name="Additional_Information" rows="11" cols="65"></textarea></dd> </dl> </fieldset> <fieldset> <legend>Send Email To Us</legend> <dl> <dt><label for="submit">Submit Form</label></dt> <dd><input class="inputsubmit" type="submit" id="submit" name="submit" value="Let us Know!" /></dd> </dl> </fieldset> </form> </div> <!--#endif --> <!-- InstanceEndEditable --> <!--#include virtual="/global/ssi/2009-fs2-contribute2.shtml" --> </div> <!-- CLOSE content-wrapper --> <!--#include virtual="/global/ssi/2009-fs2-footer.shtml" --> </div> <!-- CLOSE page-wrapper --> </body> <!-- InstanceEnd --></html> Similar TutorialsOkay first things first. Firebug this website http://www.locksmith.com/ You will see that they have a script in the head tag. That script is: Quote: <script class="yext-synd-74qWXpBkYak="> (function () { var el = document.createElement('script'); el.async = true; el.src = '//s.yext-listings.com/yext?aid=74qWXpBkYak%3D&city=&state=&zip=&latitude=&longitude='; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(el); })(); </script> They also have a form. That form is: Quote: <form title="Enter your zip and find a qualified, local locksmith" action="results.asp" method="POST"> <p><font style="font-size: 19px; font-weight: 700">FIND A LOCKSMITH</font> <input type="text" value="14646" style="font-family: Arial; font-size: 22px; color: #666666; font-weight:bold;" onclick="this.value=''" size="5" name="zip"> <input type="image" style="position: relative; top:5px" name="B1" src="images/smallgo2.jpg"> </p> </form> When you enter your zip code into that form, I think it is passed to the el.src variable as a parsed string and sent to s.yext-listings.com/ like this: //s.yext-listings.com/yext?aid=74qWXpBkYak%3D&city=&state=&zip=INSERT_ZIP_CODE_PASSED_FROM_THE_FORM_HERE&latitude=&longitu de= When you click the submit button on the form with an input zip code, it takes you to a page where there is a huge DIV block with this script executing inside it: Quote: <script class="yext-synd-74qWXpBkYak="> (function () { var el = document.createElement('script'); el.async = true; el.src = '//s.yext-listings.com/yext?aid=74qWXpBkYak%3D&city=&state=&zip=33405&latitude=&longitude='; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(el); })(); </script> Well the result on the second page is a listing pulled from a database and laid out in the second page in a DIV block. My question! How do I emulate this on my website? I have the Yext service. I have been on the phone with the company for over a week now and I cant get any technical support on the integration. Apparently they are having a lot of lay offs and technical support is unavailable. I am assuming that I need to build a form in HTML and have it pass the zip code to that JavaScript snippet somehow? I also want to know how the JavaScript on the second page renders a listing result from that passed form value? Thank you so much for the help in advance. I know you guys can figure this out before I do. Hi, So I think I can't see the trees for the forest. I'm pretty good at code and usually work out the answer myself. I am doing some work for a client, working on some code written by someone else. It is a form, and for some reason the validation isn't working. The form sends with or without data entered into the mandatory fields. I can't look at the code anymore.. Is this the correct place I would ask for help with such a thing? Thanks kindly. I have a script: PHP Code: <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src="" + gaJsHost + "google-analytics.com/ga.js" type="text/javascript"%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-13289331-1"); pageTracker._trackPageview(); } catch(err) {}</script> But firefox detects here an error which is: error: PHP Code: missing ) after argument list [Break on this error] document.write(unescape("%3Cscript src..."text/javascript"%3E%3C/script%3E"));n How I can fix that, because I didn't see what is wrong with ) symbol. Hy guys i have this error uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://www.tgi.com.pt/merdo/scroll/ :: anonymous :: line 435" data: no] the problem is this code Code: <script type="text/javascript"> var gal = { init : function() { if (!document.getElementById || !document.createElement || !document.appendChild) return false; if (document.getElementById('gallery')) document.getElementById('gallery').id = 'jgal'; var li = document.getElementById('jgal').getElementsByTagNa me('li'); li[0].className = 'active'; for (i=0; i<li.length; i++) { li[i].style.backgroundImage = 'url(' + li[i].getElementsByTagName('img')[0].src + ')'; li[i].style.backgroundRepeat = 'no-repeat'; li[i].title = li[i].getElementsByTagName('img')[0].alt; gal.addEvent(li[i],function() { var im = document.getElementById('jgal').getElementsByTagNa me('li'); for (j=0; j<im.length; j++) { im[j].className = ''; } this.className = 'active'; }); } }, addEvent : function(obj, type, fn) { if (obj.addEventListener) { obj.addEventListener(type, fn, false); } else if (obj.attachEvent) { obj["e"+type+fn] = fn; obj[type+fn] = function() { obj["e"+type+fn]( window.event ); } obj.attachEvent("on"+type, obj[type+fn]); } } } gal.addEvent(window,'load', function() { gal.init(); }); </script> I thin this is a conflict between fancybox plug in and the script above http://www.tgi.com.pt/merdo/scroll/ I really need help... Thanks When running my PHP code locally I am recieving the following error: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; BTRS26718; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.2; OfficeLiveConnector.1.5; OfficeLivePatch.1.3; Tablet PC 2.0) Timestamp: Thu, 7 Apr 2011 15:47:06 UTC Message: Object doesn't support this property or method Line: 4 Char: 1 Code: 0 URI: http://localhost/MowingSch.php ********************* * Selected Code ********************* Code: // JavaScript <script type='text/javascript'> function insCell(p1){ var wi = document.getElementById('Mowing').getElementsByName(p1).getElementsByTagName('td').length; if (wi == 3) { var x=document.getElementById(p1).insertCell(3); x.innerHTML='<?PHP echo $n; ?>'; var x=document.getElementById(p1).insertCell(4); x.innerHTML='<?PHP echo $p; ?>'; var x=document.getElementById(p1).insertCell(5); x.innerHTML='<?PHP echo $e; ?>'; } else { alert('Date selected is already assigned!'); } } </script> Code: // PHP Code $x = 0; for ($r = 0; $r <=27; $r++){ $id = 'tr'.$r; echo "<tr id=$id><TD><input id='SignUp' name=$id type='image' src='mow.png' name='mow' onclick='insCell($id)'></TD>"; for ($c = 0; $c <= 4; $c++) { if($data[$x + $c] <> ''){ echo "<td>" . $data[$x + $c] . "</td>"; } } echo "</tr>"; $x = $x + 5; } Would appreciate ANY assistance! Thanks. I am getting an error with a script and can't seem to figure out the problem. Firebug Error message: Error: document.forms[myform] is undefined Source File: https://www.domain.com/js/remember.js Line: 24 I have attached the HTML page and the remote javascript file. The script instructions said to include an onload action in the <BODY> tag as follows: <body background="/images/gold2.gif" onLoad="loadCookie(); displayFormData('my_form');"> BUT I was trying to use an even loader in the remote js file instead. Any help would be greatly appreciated. Hey guys, I'm a student taking JavaScript classes, I really like it so far and hope to really understand it in the next couple weeks. I'm doing my homework and just successfully coded a calendar (didn't take me very long, like I said, I'm catching on pretty quick and having fun) Having said that I'm not interested in getting any coding help, I simply like to further understand what I'm doing because I'm taking an online class. I'm going to show you my html and javascript file and I really need to understand why my address footer is in the middle? I have some HTML knowledge and know that since I put the address code at the bottom it should show up at the bottom. I deleted the linked .js file and it suddenly appeared at the bottom, therefore I'm thinking it has something to do with my javascript code. Does javascript act differently? Like I said, I'm not looking for anyone posting any kind of code, I'm just trying to understand what it is doing. Code: <title>Yearly Calendar</title> <link href="styles.css" rel="stylesheet" type="text/css" /> <link href="yearly.css" rel="stylesheet" type="text/css" /> <script src="yearly.js" type="text/javascript"></script> </head> <body> <div id="head"> <img style="float: right; border: 1px solid orange" src="photo.jpg" alt="" /> <img src="ccc.jpg" alt="Chamberlain Civic Center" /> </div> <div id="links"> <table><tr> <td><a href="#">Home</a></td><td><a href="#">Tickets</a></td> <td><a href="#">Events</a></td><td><a href="#">Directions</a></td> <td><a href="#">Hours</a></td><td><a href="#">Calendar</a></td> <td><a href="#">Tour</a></td><td><a href="#">Contact Us</a></td> </tr></table> </div> <div id="main" align="center"> <h1>Yearly Calendar</h1> <center><script type="text/javascript"> yearly() </script> </center> </div> <address> The Chamberlain Civic Center · 2011 Canyon Drive · Chamberlain, SD 57325 · (800) 555-8741 </address> </body> </html> Code: function yearly(calDate) { if (calDate == null) calendarDay=new Date() else calendarDay = new Date(calDate); var currentTime= calendarDay.getTime(); var thisYear= calendarDay.getFullYear(); document.write("<table id='yearly_table'><tr>"); document.write("<th id='yearly_title' colspan='4'>"); document.write(thisYear); document.write("</th>"); document.write("</tr>"); var monthNum = -1; for (var i=1; i<=3; i++) { document.write("<tr>") for (var j=1; j<=4; j++) { monthNum++; calendarDay.setDate(1); calendarDay.setMonth(monthNum); writeMonthCell(calendarDay, currentTime); } }write.document("</tr>"); write.document("</table>") } function writeMonthCell(calendarDay, currentTime) { document.write("<td class='yearly_months'>"); writeMonth(calendarDay, currentTime); document.write("</td>"); } function writeMonth(calendarDay, currentTime) { document.write("<table class='monthly_table'>"); writeMonthTitle(calendarDay); writeDayNames() writeMonthDays(calendarDay, currentTime); document.write("</table>"); } function writeMonthTitle(calendarDay) { var monthName = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); var thisMonth=calendarDay.getMonth(); document.write("<tr>"); document.write("<th class='monthly_title' colspan='7'>"); document.write(monthName[thisMonth]); document.write("</th>"); document.write("</tr>"); } function writeDayNames() { var dayName = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat"); document.write("<tr>"); for (var i=0;i<dayName.length;i++) { document.write("<th class='monthly_weekdays'>"+dayName[i]+"</th>"); } document.write("</tr>"); } function daysInMonth(calendarDay) { var thisYear = calendarDay.getFullYear(); var thisMonth = calendarDay.getMonth(); var dayCount = new Array(31,28,31,30,31,30,31,31,30,31,30,31); if ((thisYear % 4 == 0)&&((thisYear % 100 !=0) || (thisYear % 400 == 0))) { dayCount[1] = 29; } return dayCount[thisMonth]; } function writeMonthDays(calendarDay, currentTime) { var weekDay = calendarDay.getDay(); document.write("<tr>"); for (var i=0; i < weekDay; i++) { document.write("<td></td>"); } var totalDays = daysInMonth(calendarDay); for (var dayCount=1; dayCount<=totalDays; dayCount++) { calendarDay.setDate(dayCount); weekDay = calendarDay.getDay(); writeDay(weekDay, dayCount, calendarDay, currentTime); } document.write("</tr>"); } function writeDay(weekDay, dayCount, calendarDay, currentTime) { if (weekDay == 0) document.write("<tr>"); if (calendarDay.getTime() == currentTime) { document.write("<td class='monthly_dates' id='today'>"+dayCount+"</td>"); } else { document.write("<td class='monthly_dates'>"+dayCount+"</td>"); } if (weekDay == 6) document.write("</tr>"); } I really can't figure this out... Hopefully you guys may have an idea. Basically I have an Ajax chat that stores a cookie. The first thing it does is checks to see if a cookie is set, if it's not it loads a box to where you can type your name (if it is it skips this), then it allows you to chat. The way I have this set up is on the index, I have a command that loads a php file. I pass through the html a variable... Code: ajaxFunction(3); When it gets to ajaxFunction(funct) I have this script; Code: if(funct == 1){ var source="file2.php"; var name = document.getElementById('name').value; status = 1; var queryString = "?name=" + name + "&status=" + status; } if(funct == 2){ var source="file1.php"; var shout = document.getElementById('shout').value; var color = document.getElementById('color').value; var bold = document.getElementById('bold').value; var queryString = "?shout=" + shout + "&color=" + color + "&bold=" + bold; } if(funct == 3){ var source="file2.php"; var name = document.getElementById('dfdf').value; status = 2; var queryString = "?name=" + name + "&status=" + status; } When the program first loads, it runs command 3 which checks to see if a cookie is set. If it is set, it returns a form Code: ................<INPUT TYPE=\"checkbox\" NAME=\"bold\" ID=\"bold\"> <input type=\"button\" onclick=\"ajaxFunction(2)\" value=\"Shout\"> ajaxFunction 2 then loads the chat box. If the cookie isn't set, it loads ajax function(1) which prompts their user for the name. The prompt for the name and the test for the cookie are in the same php file. I have it to where it gets the "status" and it runs the test in this order. PHP 1. Check to see if the person has a cookie (regardless to status) if true, run file1.php 2. If the person does not have a cookie set but status = 2, returns the prompt for the user to set a name. Code: echo "<form name=\"cookiedata\"> Name: <input type=\"text\" name=\"name\" id=\"name\" onChange=\"ajaxFunction(1)\" onkeypress=\"{if (event.keyCode==13)ajaxFunction(1)}\"> <input type=\"button\" onclick=\"ajaxFunction(1)\" value=\"Save\"> </form> "; //note, this actually replaces a div on the main page and does the prompt 3. If the person has a name set and is setting a cookie now, status = 1 then run file1.php Now the weird thing is, This thing works entierly on firefox... but for some reason when it loads in ie, i don't get the chat box. I don't get any errors either. For some reason, it doesn't seem to like the variable that is passed through to the php which is done like Code: var command = ""+source+""+queryString+""; ajaxRequest.open("GET", command, true); and recieved by php like Code: <?php include('config.php'); $status=$_GET['status']; $name = $_GET['name']; if($status==1){ do some code }else if($status==2){ do some code }.....................?> What is going on? How do I fix this with out splitting up the file in to two files? (before, it went to two seperate files, and it worked great... now they are both in the same file with a condition statement and nothing is working?) I was working on this script to change text with javascript and I ran into a problem. The code goes like this: PHP Code: <area shape="rect" coords="128,174,256,203" href="#" onClick="document.getElementById('content').innerHTML='<p class=first>Welcome to the first release of my Now every time I use an apostrophe in a word then when I click the link that corresponds to that writing, it doesn't do anything. Here's the link to my website: http://bittipiilo.com/msx/ By default you are on the Home tab. Then when you click either Gallery or Services and try to go back to Home, nothing happens. Can someone help me? Hi, my website name is marutiindia.in. I am using lof k2 scroller module along with image magnifier plugin developed by Vtem. The problem is I get JS error in scroller module JS file when I try to enable both these extensions at the same time. If I disable image magnifier plugin there is no error. I don't know what are these errors but I get the following error: Code: Uncaught TypeError: Object #<Object> has no method 'getElement' Class.initialize script_12.js:27 (anonymous function) mootools-more.js:29 i.extend.$owner mootools-core.js:136 (anonymous function) mootools-core.js:131 (anonymous function) Please help me. Thanks. Hi, JSLint, is fantastic! However, it just shows errors -- no correction. Are there any online tools that are able to find and correct errors, especially missing semicolons at the end of statements? Thanks in advance! Best Rain Lover Hi all, I am working on a page that is using an image slider and a scrolling set of images and there seems to be some sort of conflict with the two because they both work on there own but as soon as they are both on the page one stops working. I have posted the javascript below in the hope that someone can point me in the right direction. I am anovice at best with javascript. I hope someone can help as I have looked everywhere Code: <script type="text/javascript" src="js/jquery.js" ></script> <script type="text/javascript" src="js/jquery-ui.min.js" ></script> <script type="text/javascript" src="js/jqueryslidemenu.js"></script> <script type="text/javascript"> $(document).ready(function(){ //$("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true); $("#featured").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true); }); </script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"> </script> <!--<script type="text/javascript" src="/js/common.js"></script>--> <script type="text/javascript" src="http://simplyscroll.googlecode.com/files/jquery.simplyscroll-1.0.4.min.js"></script> <link rel="stylesheet" href="jquery.simplyscroll-1.0.4.css" media="all" type="text/css"> <script type="text/javascript"> (function($) { $(function() { $("#scroller").simplyScroll({ autoMode: 'loop' }); }); })(jQuery); </script> this is how i call the editor: Code: <!-- editor --> <? include "js/editor/buttons.php"; ?> <iframe id="textbox" class="Eddietor" src="js/editor/editor.php"></iframe><br /> <input type="hidden" id="content" name="content"> <!-- /editor --> and this is editor.js: Code: window.onload = function() { Editor = document.getElementById('textbox').contentWindow.document; Editor.designMode = "on"; document.forms[0].onsubmit = function() { var text = document.getElementById('text'); text.value = Editor.body.innerHTML; } } function doColor(colour) { document.getElementById("textbox").contentWindow.focus(); document.getElementById("textbox").contentWindow.document.execCommand("forecolor",false, colour); } function doClick(command) { document.getElementById("textbox").contentWindow.focus(); document.getElementById("textbox").contentWindow.document.execCommand(command, false, null); } function doLink() { var mylink = prompt("URL:", "http://"); if ((mylink != null) && (mylink != "")) { document.getElementById("textbox").contentWindow.focus(); document.getElementById('textbox').contentWindow.document.execCommand("CreateLink",false,mylink); } } function doImage() { myimg = prompt('URL:', 'http://'); document.getElementById("textbox").contentWindow.focus(); document.getElementById('textbox').contentWindow.document.execCommand("InsertImage", false, myimg); } another script i made is having problems with the ID="textbox" , it might be fixed if i change id and start using name="textbox" instead, but i don't know how to do this in js. need to edit the editor.js and change id="textbox"->to->name="textbox" can anyone help me? i got no idea how to use the getElementByName thingie , i'm trying to do this for 4 hours already and still no go. appreciated. Hi Everyone, Iv got a button in my HTML5 document that when clicked gives an error. The button is coded as follows: Code: <input type="button" onclick="startGame();" value="Play!" /> The startGame function is held in an external JavaScript file. Whenever i run the code and click on the button i get an error that says startGame is not defined. Any ideas? Thanks, Luke Hi, I have been programming javascript for a couple months now and this is the first problem I've run into with no readily available resolution. I'm trying to get an inheritance chain setup, so that methods can be overriden. I want to use the prototype to contain the functions, but to have every instance have different variables. I tried doing this by checking the type of every variable in the class using a for loop, but something in this for loop is crashes Mozilla entirely and crashes the tab in Chrome. Here's the for loop that is bothering me: Code: for (var key in newClass) { if (typeof(newClass[key]) === 'function') { JClass.prototype[key] = newClass[key]; } else { JClass[key] = newClass[key]; } } Let me know if the full class would be better. Hi, Im currently building my first website, I'm trying to use a JQuery Slider effect for a top banner, however I seem to be getting a syntax error after the javascript. Any ideas? Ive attached a screenshot of the code Thanks Simon I am adding a Facebook Like button to my website using their JavaScript SDK. Everything looks good in Firefox, but in Internet Explorer 8 I'm getting a page error, and after the Like button is pressed, it produces a white box underneath, obscuring the next several lines (despite adding a height parameter). The error message says: Message: Object doesn't support this property or method XFBML Line: 16 Char: 2517 Code: 0 URI: http://static.ak.facebook.com/connec.../Connect/XFBML I experimented with a blank page http://www.positivelyfeminine.org/re.../cd/blank1.htm and everything looked fine until I added the Intense Debate code. So, I think there is some kind of conflict between the Facebook and the Intense Debate code but can't figure out where. Any suggestions would be appreciated! My website has 11 drop down lists containing different data fields. getvalues(), getvalues_1(),...getvalues_10() are user defined functions which store the value of the data field selected by the user from the drop down list. And then using Switch case statement I assign a particular value to a variable depending on what value the user selected from the drop down list. When I checked the code using 'Firebug' error console, I got two different kinds of syntactical errors, such as: 1. Error: syntax error Line: 484, Column: 36 Source Code: var groom_age = function getvalues(); <- The first kind of error points towards the semicolon And the error was present for all the 11 drop down lists (all pointing towards the semicolon) Now, when I removed the semicolon while calling the function get_values(), I got a second type of syntax error: 2. syntax error: switch (groom_age) . Error for all switch case statements The deceleration of the function getvalues() is as follows: Code: <script type = "text/javascript"> function getvalues() { var val = document.Age.Groomage.value; var si = document.Age.Groomage.selectedIndex; if (si != 0) { var textval = document.Age.Groomage.options[si].text; return textval; } } </script> The JavaScript code for the Switch Case statement is as follows: Code: <script type="text/javascript"> var age; var groom_age = function getvalues() switch(groom_age) { case '23': age = 1.6; break; case '24': age = 1.8; break; case '25': age = 1.7; break; case '26': age = 1.8; break; case '27': age = 1.9; break; case '28': age = 1.75; break; case '29': age = 1.7; break; case '30': age = 1.4; break; case '31-35': age = 1.8; break; case '36-40': age = 1.9; break; case '41-45': age = 1.75; break; case '46-50': age = 1.7; break; case '51+': age = 1.4; break; default: alert ('Please select an option'); } </script> <script type="text/javascript"> var caste; var groom_caste = function getvalues_1() switch(groom_caste) { case 'Brahmin' : caste = 2.0; break; case 'Bania': caste = 1.8; break; case 'Kayastha' : caste = 1.6; break; case 'Kshatriya' : caste = 2.0; break; case 'Dalit': caste = 1.8; break; case 'Maravar' : caste = 1.6; break; case 'Mudaliar' : caste = 2.0; break; case 'Jat': caste = 1.8; break; case 'Labanas' : caste = 1.6; break; case 'Rajput' : caste = 1.6; break; default : alert ('Please select an option'); } </script> . . . . Other Switch Case Statements . . <script type="text/javascript"> var father; var groom_father = function getvalues_10(); switch(groom_father) { case 'Doctor': father= 1.8; break; case 'IAS': father = 2.0; break; case 'Engineer': father= 1.7; break; case 'Lawyer': father= 1.65; break; case 'CA': father= 1.8; break; case 'Engineer + MBA': father= 1.9; break; case 'Family Business': father= 1.2; break; default : alert ('Please select an option'); } </script> Can someone please point out to me the mistake in the code? I would be really grateful. Thanks a lot! Hi All, I am working on dot net framework 1.1.4322. From my html code of aspx file i have called a javascript function like 'onlick =javascript:saveorder()'. I have two copies of same code(identical - compared wit file compare tool) on different machine. When i run my code on one of the machine i get an error ';' expected which is a Javascript error and same time i wont get this error on another machine. When i searched on line number provided from error i saw few auto generated script which i have not putted there. Can anyone help me with the error at least with the reason. Thanks Mishigun Hi, I have a little problem with placing a javascript into a php script If the action "Change" is true then I want to open a new window with a javascript below. I get an error message: Parse error: syntax error, unexpected '<' in /home/........ on line xx On that xx line starts the Javascript What must I do to solve this problem. <?php.................... if($_REQUEST['action']=="Change") { mysql_query("UPDATE Persons SET Itemstate = '{$_REQUEST['Nr']};' WHERE Nr={$_REQUEST['Nr']};"); <SCRIPT LANGUAGE="javascript"> <!-- window.open ('Examplepage.html') --> </SCRIPT> ........ ?> |