JavaScript - Indexof Not Working
This is a snippet from a project I'm working on involving XML DOM, but the question is really about javascript. This is the problematic code.
Code: else if (nodeOccurance.IndexOf('each:') == 0) { . . . } I want the if statement to be true if the value of the variable "nodeOccurance" begins with "each:" For some reason, it's just stopping my whole script and doing nothing. Any help? Thanks, Julian Similar TutorialsHello there I'm trying to build a simple little bot that you can ask questions. I'm using the indexOf method but I'm not sure if this is the best option for what I'm trying to do. If you type 'hello' or 'how are you' it answers. Any other input results in 'Dreadfully sorry but I didn't catch that. Say again?'. Is there a way that I can search input for certain words or combinations of words and trigger a single answer? Any help appreciated. <!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>Bot</title> <script type="text/javascript"> function bot(go){var a = go.getElementsByTagName('input');var q = a[0];var t = q.value.toLowerCase();document.go.reset();if(t.indexOf('hello')!=-1){document.getElementById('bot').innerHTML = "Hello to you.";return false;}if(t.indexOf('how are you')!=-1){document.getElementById('bot').innerHTML = "I am functioning within acceptable parameters, thank you.";return false;};go.action=document.getElementById('bot').innerHTML = "Dreadfully sorry but I didn't catch that. Say again?"; return false;}; </SCRIPT> </head> <body onLoad="document.go.q.focus()"> <div align="center"> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <form name="go" onsubmit='return bot(go)' id="go" action=""><input name='q' type='text' /><input name='' type='hidden' /></form> <p> </p><div id="bot" align="center"></div> </div> </body> Hi, I am trying to build a bookmarklet to use on the swiss legislation website. All the pages are available in several languages and I want to be able to switch with one button from french to german and from german to french. As an example, the URLs are as follow for the same page: in French: http://www.admin.ch/ch/f/rs/311_0/index2.html in German: http://www.admin.ch/ch/d/sr/311_0/index2.html So I built quite easily two bookmarklets to switch FR-DE and DE-FR: Code: javascript: var str = window.location.pathname;str = str.replace("f/rs", "d/sr");window.location = str; Code: javascript: var str = window.location.pathname;str = str.replace("d/sr", "f/rs");window.location = str; But when I try to get a single script by using if/else, I cannot manage to have the "else" part working: Code: javascript: var str = window.location.pathname; if (location.pathname.indexOf("d/rs") < 0) { str = str.replace("f/rs", "d/sr"); window.location = str; } else { str = str.replace("d/sr", "f/rs"); window.location = str; } Thinking it might have to do with str.replace, I tried an easier variant, but even this one does not work, the "else" part is never called: Code: javascript: var str = window.location.pathname; if (location.pathname.indexOf("d/rs") < 0) { str = str.replace("f/rs", "d/sr"); window.location = str; } else { alert('no'); }; I would appreciate any help on the matter... thanks in advance, RJ Hi, I'm trying to match a text string within a textarea node and then use a text range to set the users cursor highlighting over the word.My code for this is as follows: Code: function doHighlight(theWord, textAreaElement) { var text = textAreaElement.value; var theIndex = text.indexOf(theWord); setCaretPos(textAreaElement, theIndex, theIndex+theWord.length); } function setCaretPos(obj, start, end) { var range = obj.createTextRange(); range.moveStart('character', start); range.moveEnd('character', end - obj.value.length); range.select(); } I have a text area with the following html: Code: <TEXTAREA>blah blah sausage Frank Jones</TEXTAREA> (ie there are four lines visible to the user, the 3rd is blank). And I call the doHighlight method with 'blah blah', 'sausage' and 'frank jones' respectively. However the highlighting isnt working quite right - when I try to highlight 'blah blah', it highlights 'blah bl', when I try to highlight 'sausage' it highlights 'ausa' (the 2nd-5th characters) and when I try to highlight 'frank jones', it highlights 'nk jones'. This code seems to work fine when there is only a single line of text in the text area though - so I'm guess it's something to do with newline characters. Can anybody point me in the right direction as to how to fix this bug please? Thanks. hi all, my indexof() function is not being recognized when I enter an email address for an unsubscribe form I have on one of my pages. Additionally, the confirmation message is also not showing up when the email address IS valid. Here is my code that I am using on a PHP page: PHP Code: function Unsubscribe() { var IsValid = document.getElementById("email").value; alert(IsValid.indexOf("@")); exit; if (document.getElementById("email").value.length == 0 || IsValid.indexOf("@")) == -1) { alert("Enter a valid email address"); exit; } else { <?php $handle = @fopen("../logs/unsubscribes.txt", "a"); fputs($handle, $_POST["email"] . " " . "\r\n"); fclose ($handle); ?> alert(IsValid &&" has been unsubscribed."); <?php if (! $_POST["email"]) { //DO NOTHING } else { header("Location: http://www.google.com/"); } ?> } } //--> </script> </head> <body> <form action="" method="post" name="frm" onsubmit="Unsubscribe()"> <center><br /> Enter Your Email Address:<br /> <input type="text" id="email" name="email" /> </center> <p> <label> <center><input type="submit" id="unsubscribe" value="Unsubscribe Me" /></center> </label> </p> </form> </body> </html> to those PHP experts, I am aware of the RegEx function for validation, but I don't understand it, which is why I don't use it (in case anyone points that out). The other thing that is problematic is that the PHP code is automatically using HEADER() regardless of "email"'s value 0 down vote favorite share [g+] share [fb] share [tw] I have a fairly large program that I have simplified to show the problem that I am having. I have 2 div's under which I have an image and some text. When I hover on the image, the jQuery hover over image event fires. Through all this, I am able to get the Id's of both the images & their parent div's. However, when I try to get the index value of the Id's in an array, it always returns -1 ie... not found. Can you please help. The code is enclosed below. I am new to javascript & jQuery and hence the need of some help. Maybe the solution is very trivial. Thanks in advance. Regards, sbguy <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> var input_array = new Array("input1_Id", "input2_Id"); var div_array = new Array("div1_Id", "div2_Id"); window.onload=function(){ jQuery.ready(); img_hover_event_handler(); } //________________________________________________ function img_hover_event_handler() { var input_id = ""; var div_id = ""; var input_index, div_index; $("input.Lrollover").hover( function() { input_id = new String(this.id); input_index = new String(input_array.indexOf(div_id)); div_id = new String($(this).closest('div').attr('id')); // id of the parent div div_index = new String(div_array.indexOf(div_id)); alert(input_id + ", " + input_index + ", " + div_id + ", " + div_index); }, function() { }); } </script> </head> <body> <div id="div1_Id"> <input class="Lrollover" id="input1_Id" type="image" src="images/LGbtn_off.png" alt="Image1" /> <p id="myp1_Id">"Hello World 1"</p> </div> <br><br><br> <div id="div2_Id"> <input class="Lrollover" id="input2_Id" type="image" src="images/LGbtn_off.png" alt="Image2"/> <p id="myp2_Id">Hello World 2"</p> </div> </body> </html> Hi there! OK I need a little help as I'm not sure how to integrate this function into my form. First of all I should explain that my form doubles as a Google Search box. If you select the Google Search radio button it submits the input text to Google. It also defaults to Google if anything else other than "red", "green" or "blue" are entered. Now what I'd like to do is add a function so that if someone enters "purple is my favorite color" it recognizes the "purple" part of the string using something like .indexOf('purple'); and calls something like if(function==-1) { theForm.action = "Other choice "+ q.value; . How can I add this to my form? Thank you for any help. My form code: Code: <script> function convert(theForm){ var els = theForm.getElementsByTagName('input');// store inputs var q = els[0], color = els[1]; if(els[4].checked){// submit to google theForm.action = 'http://www.google.com/search'; return true; }; color.value = "Chosen "+ q.value +" color"; switch(q.value){// check the query case 'red': case 'green': case 'blue': location.href = color.value; return false; break; default: theForm.action="http://www.google.com/search"; break; }; return true; }; </script> <form name= "myform" onsubmit='return convert(this)'> <input name='q' type='text' /> <input name='color' type='hidden' /> <input type='submit' value=" Enter " /> <br /> <input name="searchType" type="radio" value="" checked="checked" > <label for="all"> My Form </label> <input name="searchType" type="radio" value="google" onclick="document.myform.action='http://www.google.com/search';" /> <label for="google"> Google Search </label></form> Ok, here's the page as it is right now: http://www.crackin.com/dev/index.php The paganation for the top 3 images is Sweet Pages: http://tutorialzine.com/2010/05/swee...tion-solution/ The content loading below is a page-replace script I got he http://css-tricks.com/dynamic-page-replacing-content/ And I'm also trying to integrate shadowbox (or lightbox, whichever will work) into the lower set of images. I have 2 problems right now I can't figure out, and I'm sure it somehow has to do with the fact I'm trying to mash 3 different JS addons into a single page, I'm still pretty new to this whole JS thing... First problem I'm having is that IE7 and Opera don't like the links in the upper images. Clicking a gallery image does not load the associated page below from those 2 browsers, however IE8 and FF seem to work fine. Second problem is getting shadowbox/lightbox to work on those lower images. I tried a couple different things but main thing I did is make sure the script is actually working by setting the header text to a link with shadowbox attached and that worked. That same link doesn't work when applied to the lower images (loads image in new window). Lightbox does the same thing. Thanks for any help. I hope I have this post in the right place! Any help would be very much appreciated... I have a feature on my website that allows users to choose the website background (using alternate css sheets) and then uses an externally linked javascript file to store the background choice as a cookie so it is consistent throughout the website. This works perfectly locally (i.e. when previewing my website on my computer) but now it is uploaded to my host it doesn't appear to be working. (with the same browser) My javascript is he http://www. b r p - e n v .com/javascript/backgroundchange.js (with no spaces) The website that the javascript file is linked to is http://www. b r p - e n v .com (with no spaces) In the head I have: <script type="text/javascript" src="../javascript/backgroundchange.js"></script> ...then I have: <body onload="set_style_from_cookie()"> ...and for users to choose which background: <form> <input type="image" src="../images/white-background-thumb.jpg" onclick="switch_style('bg1');return false;" name="theme" value="White" id="bg1"> etc... </form> My problem is: The background reverts back to the default when moving to a different page. This would indicate that the background choice is not being saved in cookies. But this works locally! I have tried putting the javascript directly onto each page but I still had the same problem. I hope someone can help, I will be so grateful if I can get this to work. Many thanks indeed! Hi All, I have two sites using zeroclipboard (hosted at google code) one works only in firefox and barely, the other is not working at all. It does use Flash, but I think the issue is on the js side of things. On both links, clicking the filename below the thumbnail will copy and add the link as an IMG code to a div below. *working* link http://pics.boasbysatyra.com/access/spiders.php This one only works in FF, and the clip area is offset badly. Here is the template for the zc code: Code: <div class="photo" style="float: left; padding: 4px;"> <div class="exif"><a href="[~41~]?dir=[+images_dir+]&file=[+filename+]" rel="shadowbox[exif_[+content_id+]]" title="exif data for [+filename+]" alt="exif data for [+filename+]">EXIF Data</a></div> <a class="thumb" rel="shadowbox[[+content_id+]]" href="[+images_dir+][+filename+]" title="[+title+] | [+description+]"> <img src="[+thumbs_dir+][+filename+]" alt="[+title+]" /> </a> <div class="filecode" id="d_clip_button[+filename+]">[+filename+] <script language="JavaScript"> var clip = new ZeroClipboard.Client(); clip.setText( 'http://pics.boasbysatyra.com[+images_dir+][+filename+]' ); clip.glue( 'd_clip_button[+filename+]' ); clip.addEventListener( 'onComplete', my_complete ); function my_complete( client, text ) { $('.picklist').append('<div class="piclinks">[IMG]' + text + '[/IMG]</div>'); } </script> </div> </div> And the JS for the page: Code: var needRef; //flag for page reload function pEdit(){ needRef = 1; } Shadowbox.init({ handleOversize: "resize", modal: true, initialHeight: 32, initialWidth: 400, overlayOpacity: 0.85, onClose: function(){//check for reload flag and reload if (needRef == 1){window.location.href=window.location.href;} } }); ZeroClipboard.setMoviePath('/js/zc/ZeroClipboard10.swf'); function initMenu() { $('#menu ul').hide(); $('#menu ul:first').show(); $('#menu li a').click(function() { var checkElement = $(this).next(); if ((checkElement.is('ul')) && (checkElement.is(':visible'))) { //return false; } if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) { $('#menu ul:visible').slideUp('normal'); checkElement.slideDown('normal'); return false; } }); } $(document).ready(function() { initMenu(); }); Now on to the totally broken one - it creates the elements required, but gives them a 0x0 area! http://jb.boasbysatyra.com/forum-pic...cs/nature.html Code: div class="photo" style="float: left; margin: 4px;"> <div class="exif"><a href="[~133~]?dir=[+images_dir+]&file=[+filename+]" rel="shadowbox[exif_[+content_id+]]" title="exif data for [+filename+]" alt="exif data for [+filename+]">EXIF Data</a></div> <a class="thumb" rel="shadowbox[[+content_id+]]" href="[+images_dir+][+filename+]" title="[+title+] | [+description+]"> <img src="[+thumbs_dir+][+filename+]" alt="[+title+]" /> </a> <div id="d_clip_container[+filename+]" style="position:relative; width: 120px; height: 0.5em;"> <div class="filecode" id="d_clip_button[+filename+]">[+filename+] <script language="JavaScript"> var clip = new ZeroClipboard.Client(); clip.setText( 'http://jb.boasbysatyra.com[+images_dir+][+filename+]' ); clip.glue( 'd_clip_button[+filename+]','d_clip_container[+filename+]' ); clip.addEventListener( 'onComplete', my_complete ); function my_complete( client, text ) { $('.picklist').append('<div class="piclinks">[IMG]' + text + '[/IMG]</div>'); } </script> </div> </div> </div> On this one I wrapped it as suggested on the zc site, I originally started with the code for the other site - it didn't work, so I went tweaking... Here is the JS: Code: var needRef; //flag for page reload function pEdit(){ needRef = 1; } Shadowbox.init({ handleOversize: "resize", modal: true, initialHeight: 32, initialWidth: 400, overlayOpacity: 0.85, onClose: function(){//check for reload flag and reload if (needRef == 1){needRef = 0; window.location.href=window.location.href;} } }); ZeroClipboard.setMoviePath('/js/zc/ZeroClipboard10.swf'); $(document).ready(function() { $(".dim img").fadeTo("slow", 0.65); $(".dim img").hover(function(){ $(this).fadeTo("slow", 1.0); },function(){ $(this).fadeTo("slow", 0.65); }); $('#mainContent').hide().fadeIn(1200); //When page loads... $(".tab_content").hide(); //Hide all content // $("ul.tabs li:first").addClass("active").show(); //Activate first tab // $(".tab_content:first").show(); //Show first tab content //On Click Event $("ul.tabs li").click(function() { $("ul.tabs li").removeClass("active"); //Remove any "active" class $(this).addClass("active"); //Add "active" class to selected tab $(".tab_content").hide(); //Hide all tab content var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content $(activeTab).fadeIn(); //Fade in the active ID content return false; }); }); (function($) { $(document).ready(function(){ $('.menu1').ptMenu(); $('.menu2').ptMenu({vertical:true}); }); })(jQuery); I have taken a look at this for a few days and tried many things with no luck, any help is appreciated. Thanks! hereis the html file and javascripton click of this button a html ***************************** <table class=matcolor id=topnav cellspacing=0 cellpadding=0 width=550 border=0 bgcolor="#FFCCCC"> <tbody> <tr align=middle> <td id=menu1 onMouseOver="this.className='mPrimaryOn';showmenu(this);" onClick="this.document.location.href=''" onMouseOut="this.className='mPrimaryOff';hidemenu(this);" class="mat" height="20"> <div align="center"><font color="#FF0000">Desk Top Publishing </font></div> </td> <td width=1 bgcolor=#ff9900 class="mat"></td> <td id=menu2 onMouseOver="this.className='mPrimaryOn';showmenu(this);" onClick="this.document.location.href=''" onMouseOut="this.className='mPrimaryOff';hidemenu(this);" class="mat" height="20"> <div align="center"><font color="#FF0000">Transcription</font></div> </td> <td width=1 bgcolor=#ff9900 class="mat"></td> <td id=menu3 onMouseOver="this.className='mPrimaryOn';showmenu(this);" onClick="this.document.location.href=''" onMouseOut="this.className='mPrimaryOff';hidemenu(this);" class="mat" height="20"> <div align="center"><font color="#FF0000">Accounts Processing </font></div> </td> </tr> </tbody> </table> ***************************************** <script language=JavaScript> ix = document.getElementById('tblmenu1').getBoundingClientRect(); new ypSlideOutMenu("menu1", "right",ix.left + ix.right ,ix.bottom + 10); </script> **any thing i have to alter to work in firefox please help I have a usercontrol which get inputs from the user and show the slideshows. I have added jquery.js and jqfancytransitions.js to the control. when i apply the effects dynamically it is working on local iis but the same coding is not working on iis server. The link for the page is http://www.gloriatech.com/slideshow.aspx . Actually it display the images but no effects are applied. I also checked the js files, it is in right path only.When i checked this page in firebug , it shows the error which is " Sys is undefined". I dont know how to solve it. Can anyone help me? Thanx in advance. hi jus want to ask why is the else not working in the showmore and showless function i have two div which shld conduct the same way of working which is to show the rest of the text with the show more and min the text with the show less function anyone know what my mistake is? Code: function showmore() { if (document.getElementById("mydiv1") ){ document.getElementById("mydiv1").innerHTML = ""; document.getElementById("mydiv1").innerHTML = txt1 + "<font color = '#0000FF' size = '1'><a onclick='showless();return false'>.....read less</a>";txt1; } else { document.getElementById("mydiv").innerHTML = ""; document.getElementById("mydiv").innerHTML = txt + "<font color = '#0000FF' size = '1'><a onclick='showless();return false'>.....read less</a>";txt; } } function showless() { if (document.getElementById("mydiv1")){ document.getElementById("mydiv1").innerHTML = shorttxt1 + "<font color = '#0000FF' size = '1'><a onclick='showmore();return false'>.....read more</a>"; } else { document.getElementById("mydiv").innerHTML = shorttxt + "<font color = '#0000FF' size = '1'><a onclick='showmore();return false'>.....read more</a>"; } } thanks Reply asap!!! Script::. Code: <script language="javascript"> function temp(form) { oops = ""; var sum = 0; var fld = (form.level.value); var val = fld.value.replace(/\s/g, "" ); if ( val != "") { var deg = parseFloat(fld.value); if ( isNaN(deg) || deg < 0) { fld.value = "0"; oops += "\nInvalid Level"; } else if ( deg != 0 ) { sum += Math.pow( deg, 3 );} } if ( oops != "" ) { alert("You must correct these errors:\n" + oops); return false; } form.totalexp.value = sum ; } </script> Html::. Code: <form style="text-align:center"> <p>Level</p> <p><input size=30 maxlength=30 value=0 name="level" onfocus="this.value=''"/></p> <input type=button onclick=temp(this.form) value=Calculate /> <input type=reset name=clear id=clear value=Clear /></p> <blockquote><p>Total Exp <input name="totalexp" size=40 maxlength=40 readonly=""/></p></blockquote></form> Can someone help me. Whats wrong with my js code and i am noob to J.S. Your help is most appreciated. In my website, I have a script that I need help to get working. This is my script. Code: <script language="Javascript"> <!-- if (screen.width>=1024) { document.write('<td width="20%"><table border="0" cellpadding="0" cellspacing="0" width="162"> <tr><td height="29" style="background:url("/Custom/Top2.png");color:#116111;" align="center"><b>Newest Tutorial</b></td></tr> <tr><td height="160" style="background:url("/Custom/Middle2.png") #000000;padding:5px 5px 0 5px;">$MYINF_8$</td></tr> <tr><td><img src="/Custom/Bottom2.png" border="0"></td></tr> </table> </td>'); } //--> </script> It is supposed to detect if someone has a widescreen monitor, and then add the extra box if it is widescreen. For some unknown reason, its not working. No extra box appears. Does anyone know where I went wrong? Edit: $MYINF_8$ is what goes inside the box. Hi guys, For some reason, in IE8, on product pages (Example) of my ecommerce site, the 'Size Chart' and 'Email to a Friend' popups don't work, and the product image lightbox won't work either. I have turned pop-up blocker off but they still don't work. These popups work in every other browser I have tested in, including IE7. It seems to only be IE8 that is having this problem. Here is the HTML: Code: <div class="row "> <label >Size: </label> <strong class="fl"><select name="size" id="size" onchange="checkstock(this.value)"><option value="">Select Size</option><option value="S">S</option><option value="M">M</option><option value="L">L</option><option value="XL">XL</option><option value="XXL">XXL</option></select></strong> <span style="text-decoration: underline;" class="size_chart more" title="size_chart1">+ Size Chart</span> <div style="display: none;" class="size_chart1 hide" > <div class="close"></div> <img src="http://www.projectdisobey.com/disobeyclothing/wp-content/themes/eCommerce3/images/size_chart.jpg" alt="" /> </div> <!-- size chart --> </div> Code: <ul class="fav_link"> <li class="print"> <a href="#" onclick="window.print();return false;">Print</a> </li> <li class="rss"> <a href="http://feeds.feedburner.com/DisobeyClothing">RSS</a> </li> <li class="emailtofriend"> <span style="text-decoration: underline;" class="more" title="tellafrnd_div">Email to a Friend</span> <span id="tellafrnd_success_msg_span"></span> <div style="display: none;" id="tellfrnddiv" class="tellafrnd_div hide"> <iframe src="http://www.projectdisobey.com/disobeyclothing/?page=tellafriend_form&pid=402" style="border: medium none ; width: 547px; height: 558px;" frameborder="0" ></iframe> </div> </li> <li class="share"> <div class="a2a_kit addtoany_list"> <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.projectdisobey.com/disobeyclothing/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/> </a> </div> <script type="text/javascript"><!-- var a2a_config = a2a_config || {}; a2a_config.linkname="Know Your Enemy"; a2a_config.linkurl="http://www.projectdisobey.com/disobeyclothing/?p=402"; a2a_config.color_main = "f3f3e7";a2a_config.color_border = "C0C88A";a2a_config.color_link_text = "332402";a2a_config.color_link_text_hover = "332402";a2a_config.color_bg = "7f6f2"; a2a_config.num_services = 14; //--></script><script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script> </li> </ul> Here is the Javascript: Code: <script type="text/javascript"> var closebutton='<?php bloginfo('template_directory'); ?>/library/js/closebox.png'; </script> <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/library/js/fancyzoom.js"></script> <script type="text/javascript" charset="utf-8"> $(document).ready(function() { $('div.photo a').fancyZoom({scaleImg: true, closeOnClick: true}); $('#medium_box_link').fancyZoom({width:400, height:300}); $('#large_box_link').fancyZoom(); $('#flash_box_link').fancyZoom(); }); </script> <script type="text/javascript"> /* <![CDATA[ */ $(document).ready(function(){ $('.hide').hide(); $('body').append('<div id="infoBacking"></div><div id="infoHolder" class="large"></div>'); $('#infoBacking').css({position:'absolute', left:0, top:0, display:'none', textAlign:'center', background:'', zIndex:'600'}); $('#infoHolder').css({left:0, top:0, display:'none', textAlign:'center', zIndex:'600', position:'fixed'}); if($.browser.msie){$('#infoHolder').css({position:'absolute'});} $('.more').mouseover(function() {$(this).css({textDecoration:'none'});} ); $('.more').mouseout(function() {$(this).css({textDecoration:'none'});} ); $('.more').click(function(){ if ($('.' + $(this).attr("title")).length > 0) { browserWindow() getScrollXY() if (height<totalY) { height=totalY; } $('#infoBacking').css({width: totalX + 'px', height: height + 'px', top:'0px', left:scrOfX + 'px', opacity:0.85}); $('#infoHolder').css({width: width + 'px', top:scrOfY + 25 + 'px', left:scrOfX + 'px'}); source = $(this).attr("title"); $('#infoHolder').html('<div id="info">' + $('.' + source).html() + '<p class="clear"><span class="close"><?php _e('Close X');?></span></p></div>'); $('#infoBacking').css({display:'block'}); $('#infoHolder').show(); $('#info').fadeIn('slow'); } $('.close').click(function(){ $('#infoBacking').hide(); $('#infoHolder').fadeOut('fast'); }); }); /* find browser window size */ function browserWindow () { width = 0 height = 0; if (document.documentElement) { width = document.documentElement.offsetWidth; height = document.documentElement.offsetHeight; } else if (window.innerWidth && window.innerHeight) { width = window.innerWidth; height = window.innerHeight; } return [width, height]; } /* find total page height */ function getScrollXY() { scrOfX = 0; scrOfY = 0; if( typeof( window.pageYOffset ) == 'number' ) { scrOfY = window.pageYOffset; scrOfX = window.pageXOffset; } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft; } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft; } totalY = (window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : null); totalX = (window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null); return [ scrOfX, scrOfY, totalY, totalX ]; } return false; }); /* ]]> */ </script> Anybody have any suggestions as to what the problem might be (and how I can rectify it)? If you need more info, please let me know... Thanks! I think that if there is more space between the columns that it would be easier to read, but whatever I try is not working. Just putting tabs between them is my latest idea, however, the space is not all that big. Is it possible that I have entered it wrong? Thank you, the code is below: <html> <head> <title>Exercise</title> <script type = "text/javascript"> <!-- var row = 0; var cols = 0; var sum = (row + 1); if (row ==0) { document.write("sum   square   cube"); document.write("<br>"); row++; } while((row >= 0) && (row <= 11)) { document.write(row + "\t" + (row * row) + "\t" + (row * row * row)); document.write("<br>"); row++; } // --> </script> </head> <body> <p>what? seriously, this is working?</p> </body> </html> Won't validate help...pasor error? Wtf i suck at this. Code: <?xml version="1.0" encoding="UTF-8"?> <!--Prolog Above--> <!--dataset is the name of the Root Element--> <!--Artist, Album, and, Publisher are the names of the namespaces, Ar, Al, and, Pu are the prefixes--> <dataset xmlns:Al="Album" xmlns:Ar="Artist" xmlns:Pu="Publisher" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <!--Elements, blank text is data--> <dataset> <Al:Album> <Al:Album ID =""> <Al:Genre =""></Al:Genre> <Al:AmountSold =""></Al:AmountSold> <Al:PublishDate =""></Al:PublishDate> <Al:Artist =""></Al:Artist> </Al:Album> </Al:Album> <Ar:Artist> <Ar:Artist ID =""> <Ar:Awards =""></Ar:Awards> <Ar:Location =""></Ar:Location> <Ar:Region =""></Ar:Region> <Ar:LabelID =""></Ar:LabelID> </Ar:Artist> </Ar:Artist> <Pu:Publisher> <Pu:Publisher ID =""> <Pu:AmountSold =""></Pu:AmountSold> <Pu:Artist = ""></Pu:Artist> <Pu:PublishDate =""></Pu:PublishDate> <Pu:Manager = ""></Pu:Manager> </Pu:Publisher> </Pu:Publisher> </dataset> Can you please take a look at this and tell me why it is not getting all the way thru the function and why this is not working totally. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> <script type="text/javascript"> function cabFair(start, end, time){ var base = 0; if (start = 1){ if (end = 1){ base = 5; }if (end = 2) { base = 7; }base = 8; }if (start = 2){ if (end = 1){ base = 7; }if (end = 2) { base = 5; }base = 9; }if (end = 1){ base = 8; }if (end = 2) { base = 9; }base = 5; //return(base); if (time > 20){ time1 = (time - 20); time2 = (time1 * (.3)); finalTime = (time2 + 10); }if (time > 10 && time <= 20){ time1 = (time - 10); time2 = (time1 * (.4)); finalTime = (time2 + 6); }if (time >4 && time <= 10){ time1 = (time - 4); time2 = (time1 * (.5)); finalTime = (time2 + 3); }finalTime = (time * .75); var fare = finalTime + base; return fare } </script> </head> <body> <script type="text/javascript"> //Ask user for input var start = parseInt(prompt("Enter the Starting Point", "1")); var end = parseInt(prompt("Enter the Ending Point", "2")); var time = parseInt(prompt("Enter the Total Time", "4")); //output for information document.writeln(cabFair(start, end, time) + " Is the Total Fare."); </script> </body> </html> HI, i know this must be old js because 'language' is deprecated but, I would like to know where this script gets the word 'Name:' from for the output after I entered dat to the textbox. Code: <HTML> <HEAD> <script language="javascript"> <!-- function send_onclick(frmName) { var bolSubmit; bolSubmit = true; if (frmName.email.value == "") { alert("You must enter an email address"); bolSubmit = false; } if (bolSubmit == true) { frmName.submit(frmName); } } //--> </script> </HEAD> <BODY> <form name="frmName" method="post" action="validate.asp"> Enter your name in the text box. If nothing is entered, a warning message will be displayed. <br>Only when you enter something into the text box will the page be submitted. <br><br> Please enter your name : <INPUT TYPE="TEXT" name="email" size="20"><br> <INPUT TYPE="button" name="butSent" value="Do it" language="javascript" onclick="return send_onclick(frmName)"> </form> Name : d </BODY> </HTML> I guess its from the 'name' of name='email' but how does it do it. Is this next part grabbing everything that was submitted as if a key/value pair? Code: if (bolSubmit == true) { frmName.submit(frmName); } bazz |