JavaScript - Modification To Lytebox Info Call
I'm working on a website for a freelance writer. I've used a lytebox mod to open a modal dialogue box that shows a scan of each magazine article. The code allows for an "info" button at the bottom of the window, which when clicked calls a page info.php, and populates that page with text from an [info] variable on the main page.
My question is this. I'd like to use the "info" button to call entire articles in text format from a separate php page. I don't want to insert these long articles into the main page. Is there an easy way to do this in the code? The info.php page code follows: <div class="info"><?php if (isset($_GET['info'])){ $text = $_GET['info']; $text = str_replace('<br/>',"\n",$text); } else { $text = 'This page is showing text from GET "info" variable'; } echo $text; ?></div> The entire info.php page is he http://www.mimiread.com/info.php The main lytebox.js page that I'm using is he http://www.mimiread.com/lytebox.js The code line that calls this from the main page: <a href="images/ttlnob-cover.jpg" rel="lytebox[essays-ttlnob]" rev="[info]ttlnob.html[/info]" title=""><img src="images/essays-ttlnob.jpg" border="0" alt="house beautiful, the trying to leave new orleans blues" /></a> Any help would be appreciated. Similar TutorialsOn a friend's site I am using a combination of easyslider (a slideshow script) and lytebox (probably doesn't need an intro). It can be seen in action on http://www.maisonportier.com/menu.php (then click on 'Press'). I really don't know much about Javascript so am just able to do extremely simple things such as combining two script. Now my friend want the slideshow to pause when an image is opened (using Lytebox), and to continue when the image is closed. The scripts can be found at: http://www.maisonportier.com/js/lytebox.js and http://www.maisonportier.comeasySlider1.5.js Can anybody tell me how to modify the code? Any help is greatly appreciated! Hello, I found jkmegamenu (http://www.javascriptkit.com/script/...megamenu.shtml) beneficial for my website. As there is a delay time for hiding the menu by default, however I could not succeed for the required modification to set an delay time prior to popup the menu. I paste the code below and marked the part that I know to set something for the delay for mouse enter, in red. I need your advice for the modification needed to be able to apply the same delay time prior to pop up the menu. Thanks. Code: jQuery.noConflict(); var jkmegamenu={ effectduration: 0, //duration of animation, in milliseconds delaytimer: 300, //delay after mouseout before menu should be hidden, in milliseconds //No need to edit beyond here megamenulabels: [], megamenus: [], //array to contain each block menu instances zIndexVal: 1000, //starting z-index value for drop down menu jqshimobj: null, addshim:function(jq){ jq(document.body).append('<IFRAME id="outlineiframeshim" src="'+(location.protocol=="https:"? 'blank.htm' : 'about:blank')+'" style="display:none; left:0; top:0; z-index:999; position:absolute; filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)" frameBorder="0" scrolling="no"></IFRAME>') this.jqshimobj=jq("#outlineiframeshim") }, alignmenu:function(jq, e, megamenu_pos){ var megamenu=this.megamenus[megamenu_pos] var jqanchor=megamenu.jqanchorobj var jqmenu=megamenu.jqmenuobj var menuleft=(jq(window).width()-(megamenu.offsetx-jq(document).scrollLeft())>megamenu.actualwidth)? megamenu.offsetx : megamenu.offsetx-megamenu.actualwidth+megamenu.anchorwidth //get x coord of menu //var menutop=(jq(window).height()-(megamenu.offsety-jq(document).scrollTop()+megamenu.anchorheight)>megamenu.actualheight)? megamenu.offsety+megamenu.anchorheight : megamenu.offsety-megamenu.actualheight var menutop=megamenu.offsety+megamenu.anchorheight //get y coord of menu jqmenu.css({left:265+"px", top:menutop-85+"px"}) this.jqshimobj.css({width:megamenu.actualwidth+"px", height:megamenu.actualheight+"px", left:menuleft+"px", top:menutop+"px", display:"block"}) }, showmenu:function(e, megamenu_pos){ var megamenu=this.megamenus[megamenu_pos] var jqmenu=megamenu.jqmenuobj var jqmenuinner=megamenu.jqmenuinner if (jqmenu.css("display")=="none"){ this.alignmenu(jQuery, e, megamenu_pos) jqmenu.css("z-index", ++this.zIndexVal) jqmenu.show(this.effectduration, function(){ jqmenuinner.css('visibility', 'visible') }) } else if (jqmenu.css("display")=="block" && e.type=="click"){ //if menu is hidden and this is a "click" event (versus "mouseout") this.hidemenu(e, megamenu_pos) } return false }, hidemenu:function(e, megamenu_pos){ var megamenu=this.megamenus[megamenu_pos] var jqmenu=megamenu.jqmenuobj var jqmenuinner=megamenu.jqmenuinner jqmenuinner.css('visibility', 'hidden') this.jqshimobj.css({display:"none", left:0, top:0}) jqmenu.hide(this.effectduration) }, definemenu:function(anchorid, menuid, revealtype){ this.megamenulabels.push([anchorid, menuid, revealtype]) }, render:function(jq){ for (var i=0, labels=this.megamenulabels[i]; i<this.megamenulabels.length; i++, labels=this.megamenulabels[i]){ if (jq('#'+labels[0]).length!=1 || jq('#'+labels[1]).length!=1) //if one of the two elements are NOT defined, exist return this.megamenus.push({jqanchorobj:jq("#"+labels[0]), jqmenuobj:jq("#"+labels[1]), jqmenuinner:jq("#"+labels[1]).children('ul:first-child'), revealtype:labels[2], hidetimer:null}) var megamenu=this.megamenus[i] megamenu.jqanchorobj.add(megamenu.jqmenuobj).attr("_megamenupos", i+"pos") //remember index of this drop down menu megamenu.actualwidth=megamenu.jqmenuobj.outerWidth() megamenu.actualheight=megamenu.jqmenuobj.outerHeight() megamenu.offsetx=megamenu.jqanchorobj.offset().left megamenu.offsety=megamenu.jqanchorobj.offset().top megamenu.anchorwidth=megamenu.jqanchorobj.outerWidth() megamenu.anchorheight=megamenu.jqanchorobj.outerHeight() jq(document.body).append(megamenu.jqmenuobj) //move drop down menu to end of document megamenu.jqmenuobj.css("z-index", ++this.zIndexVal).hide() megamenu.jqmenuinner.css("visibility", "hidden") megamenu.jqanchorobj.bind(megamenu.revealtype=="click"? "click" : "mouseenter", function(e){ var menuinfo=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))] clearTimeout(menuinfo.hidetimer) //cancel hide menu timer return jkmegamenu.showmenu(e, parseInt(this.getAttribute("_megamenupos"))) }) megamenu.jqanchorobj.bind("mouseleave", function(e){ var menuinfo=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))] if (e.relatedTarget!=menuinfo.jqmenuobj.get(0) && jq(e.relatedTarget).parents("#"+menuinfo.jqmenuobj.get(0).id).length==0){ //check that mouse hasn't moved into menu object menuinfo.hidetimer=setTimeout(function(){ //add delay before hiding menu jkmegamenu.hidemenu(e, parseInt(menuinfo.jqmenuobj.get(0).getAttribute("_megamenupos"))) }, jkmegamenu.delaytimer) } }) megamenu.jqmenuobj.bind("mouseenter", function(e){ var menuinfo=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))] clearTimeout(menuinfo.hidetimer) //cancel hide menu timer }) megamenu.jqmenuobj.bind("click mouseleave", function(e){ var menuinfo=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))] menuinfo.hidetimer=setTimeout(function(){ //add delay before hiding menu jkmegamenu.hidemenu(e, parseInt(menuinfo.jqmenuobj.get(0).getAttribute("_megamenupos"))) }, jkmegamenu.delaytimer) }) } //end for loop if(/Safari/i.test(navigator.userAgent)){ //if Safari jq(window).bind("resize load", function(){ for (var i=0; i<jkmegamenu.megamenus.length; i++){ var megamenu=jkmegamenu.megamenus[i] var jqanchorisimg=(megamenu.jqanchorobj.children().length==1 && megamenu.jqanchorobj.children().eq(0).is('img'))? megamenu.jqanchorobj.children().eq(0) : null if (jqanchorisimg){ //if anchor is an image link, get offsets and dimensions of image itself, instead of parent A megamenu.offsetx=jqanchorisimg.offset().left megamenu.offsety=jqanchorisimg.offset().top megamenu.anchorwidth=jqanchorisimg.width() megamenu.anchorheight=jqanchorisimg.height() } } }) } else{ jq(window).bind("resize", function(){ for (var i=0; i<jkmegamenu.megamenus.length; i++){ var megamenu=jkmegamenu.megamenus[i] megamenu.offsetx=megamenu.jqanchorobj.offset().left megamenu.offsety=megamenu.jqanchorobj.offset().top } }) } jkmegamenu.addshim(jq) } } jQuery(document).ready(function(jq){ jkmegamenu.render(jq) }) I have been successfully using the following "myAjax" function to load text file information from the server. Code: // ajax.js // From: http://www.webdeveloper.com/forum/showthread.php?t=245681 // and: http://www.webdeveloper.com/forum/showthread.php?t=245694 // From: http://codingforums.com/showthread.php?t=143412&highlight=file var myAjax = { TextInformation : '', myAjaxIO : function (U, V) { //LA MOD String Version. A tiny ajax library. by, DanDavis var X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest(); X.open(V ? 'PUT' : 'GET', U, false ); X.setRequestHeader('Content-Type', 'text/html'); X.send(V ? V : ''); return X.responseText; }, doLoad : function (filename) { this.TextInformation = this.myAjaxIO(filename); }, getTextInfo : function () { // alert(this.TextInformation); // for testing purposes return this.TextInformation } } /* example function Load_and_Show(filename) { myAjax.doLoad(filename); document.getElementById('TArea').value=myAjax.getTextInfo(); } */ After I load the text file, I store the text "records" into an array by doing something like this: Code: var Recs = myAjax.getTextInfo().split('}'); Where the '}' character is my record delimiter. It could just as easily be '\n' or '\r' or the like. Again, I am not having any problems doing it this way as it suits my current needs. Now the question(s) 1. Does the call to read the text data from the external file always read in the entire contents or can I read one line or delimited record at a time and store it to the array directly without the text storage? 2. If the text is always read completely (my suspicion), can I safely delete the "TextInformation" after I convert to the array format? Is there any memory penalty for doing it this way as the text information can be somewhat lengthly and I don't like the idea of having doubled memory usage when I only need the information in array format anyway? This is the idea I am considering, but I don't know if there are drawback to this method of if there is a better way to accomplish the task. Code: // ajax.js // From: http://www.webdeveloper.com/forum/showthread.php?t=245681 // and: http://www.webdeveloper.com/forum/showthread.php?t=245694 // From: http://codingforums.com/showthread.php?t=143412&highlight=file var myAjax = { TextInformation : '', TextArrayInfo : [], myAjaxIO : function (U, V) { //LA MOD String Version. A tiny ajax library. by, DanDavis var X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest(); X.open(V ? 'PUT' : 'GET', U, false ); X.setRequestHeader('Content-Type', 'text/html'); X.send(V ? V : ''); return X.responseText; }, doLoad : function (filename) { this.TextInformation = this.myAjaxIO(filename); }, getTextInfo : function () { // alert(this.TextInformation); // for testing purposes return this.TextInformation }, doArrayConvert : function() { TextArrayInfo = this.TextInformation.split('}'); // assumes '}' is separator character this.TextInformation = ''; }, getTextArrayLength : function() { return this.TextArrayInfo.length; }, getTextArrayAt : function(ptr) { return this.TextArrayInfo[ptr]; } } /* example function Load_and_Show(filename) { myAjax.doLoad(filename); document.getElementById('TArea').value=myAjax.getTextInfo(); } function Convert_to_Array() { myAjax.doArrayConvert(); } var rec = myAjax.getTextArrayAt(0); // gets record element '0' // or rec = myAjax.getTextArrayAt(myAjax.getTextArrayLength()-1); // get last element */ Hi all, I'm justing wondering about the behavior of JS in regards to adding elements, suppose I have something like this Code: <div id="myDiv"></div> ... function test() { for (i=0 i<100; i++) { var obj = document.create("div"); // do stuff to style div and set content document.getElementById("myDiv").appendChild(obj); } // DO SOMETHING WITH ONE OF THESE DIVS } I'm just wondering at the point I hit that "// DO SOMETHING WITH ONE OF THESE DIVS", are all the divs I have added in the DOM available to access? I ask because I have some code at work in which a tester is reporting an error that happens which I can't reproduce, and they and others have had it a few times. The only way I can explain it in my mind is if the div is not available to me at the time of execution. So I'm just looking to rule it out or confirm my hunch. Is document.getElementById("myDiv").appendChild(obj); synchronous and the next line of code wont execute until the DOM is ready or is it in fact a asynchronous call and therefore adding alot of elements to the DOM could result in a lag so some divs or not available straight away. Any information much appreciated, I hope I have been clear enough. I'm using IE7 and so are the testers. Thanks, Dale Hello, Im a coding noob and trying to make this widget display in 3 columns. Can some one help me? I am able to do it with simple css modifications, but the container still only shows up as 1 column rather than 3. Any ideas? Code: <!-- Show static HTML/CSS as a placeholder in case js is not enabled - javascript include will override this if things work --> <style type="text/css" media="screen"> .gr_custom_container_1318614690 { /* customize your Goodreads widget container here*/ border: 1px solid gray; -moz-border-radius:10px; -webkit-border-radius:10px; padding: 10px 5px 10px 5px; background-color: #FFFFFF; color: #000000; width: 300px } .gr_custom_header_1318614690 { /* customize your Goodreads header here*/ border-bottom: 1px solid gray; width: 100%; margin-bottom: 5px; text-align: center; font-size: 120% } .gr_custom_each_container_1318614690 { /* customize each individual book container here */ width: 100%; clear: both; margin-bottom: 10px; overflow: auto; padding-bottom: 4px; border-bottom: 1px solid #aaa; } .gr_custom_book_container_1318614690 { /* customize your book covers here */ overflow: hidden; height: 60px; float: left; margin-right: 4px; width: 39px; } .gr_custom_author_1318614690 { /* customize your author names here */ font-size: 10px; } .gr_custom_tags_1318614690 { /* customize your tags here */ font-size: 10px; color: gray; } .gr_custom_rating_1318614690 { /* customize your rating stars here */ float: right; } </style> <div id="gr_custom_widget_1318614690"> <div class="gr_custom_container_1318614690"> <h2 class="gr_custom_header_1318614690"> <a href="http://www.goodreads.com/review/list/6131699-kevin?shelf=read&utm_medium=api&utm_source=custom_widget" style="text-decoration: none;">Kevin's bookshelf: read</a> </h2> <div class="gr_custom_each_container_1318614690"> <div class="gr_custom_book_container_1318614690"> <a href="http://www.goodreads.com/review/show/202292893?utm_medium=api&utm_source=custom_widget" title="The Great Gatsby"><img alt="The Great Gatsby" border="0" src="http://photo.goodreads.com/books/1273944449s/4671.jpg" /></a> </div> <div class="gr_custom_rating_1318614690"> <img alt="3 of 5 stars" height="15" src="http://d16kthk4voxb3t.cloudfront.net/images/layout/stars/red_star_3_of_5.png?1318545374" title="3 of 5 stars, liked it" width="75" /> </div> <div class="gr_custom_title_1318614690"> <a href="http://www.goodreads.com/review/show/202292893?utm_medium=api&utm_source=custom_widget">The Great Gatsby</a> </div> <div class="gr_custom_author_1318614690"> by <a href="http://www.goodreads.com/author/show/3190.F_Scott_Fitzgerald">F. Scott Fitzgerald</a> </div> </div> <div class="gr_custom_each_container_1318614690"> <div class="gr_custom_book_container_1318614690"> <a href="http://www.goodreads.com/review/show/202292900?utm_medium=api&utm_source=custom_widget" title="Where the Sidewalk Ends"><img alt="Where the Sidewalk Ends" border="0" src="http://photo.goodreads.com/books/1168052448s/30119.jpg" /></a> </div> <div class="gr_custom_rating_1318614690"> <img alt="5 of 5 stars" height="15" src="http://dkt27ch3b0vq7.cloudfront.net/images/layout/stars/red_star_5_of_5.png?1318545374" title="5 of 5 stars, it was amazing" width="75" /> </div> <div class="gr_custom_title_1318614690"> <a href="http://www.goodreads.com/review/show/202292900?utm_medium=api&utm_source=custom_widget">Where the Sidewalk Ends</a> </div> <div class="gr_custom_author_1318614690"> by <a href="http://www.goodreads.com/author/show/435477.Shel_Silverstein">Shel Silverstein</a> </div> </div> <div class="gr_custom_each_container_1318614690"> <div class="gr_custom_book_container_1318614690"> <a href="http://www.goodreads.com/review/show/202292913?utm_medium=api&utm_source=custom_widget" title="The Alchemist"><img alt="The Alchemist" border="0" src="http://photo.goodreads.com/books/1287827991s/865.jpg" /></a> </div> <div class="gr_custom_rating_1318614690"> <img alt="5 of 5 stars" height="15" src="http://dkt27ch3b0vq7.cloudfront.net/images/layout/stars/red_star_5_of_5.png?1318545374" title="5 of 5 stars, it was amazing" width="75" /> </div> <div class="gr_custom_title_1318614690"> <a href="http://www.goodreads.com/review/show/202292913?utm_medium=api&utm_source=custom_widget">The Alchemist</a> </div> <div class="gr_custom_author_1318614690"> by <a href="http://www.goodreads.com/author/show/566.Paulo_Coelho">Paulo Coelho</a> </div> </div> <div class="gr_custom_each_container_1318614690"> <div class="gr_custom_book_container_1318614690"> <a href="http://www.goodreads.com/review/show/202292927?utm_medium=api&utm_source=custom_widget" title="Slaughterhouse-Five"><img alt="Slaughterhouse-Five" border="0" src="http://photo.goodreads.com/books/1316813479s/4981.jpg" /></a> </div> <div class="gr_custom_rating_1318614690"> <img alt="4 of 5 stars" height="15" src="http://d2owxupnsl35mn.cloudfront.net/images/layout/stars/red_star_4_of_5.png?1318545374" title="4 of 5 stars, really liked it" width="75" /> </div> <div class="gr_custom_title_1318614690"> <a href="http://www.goodreads.com/review/show/202292927?utm_medium=api&utm_source=custom_widget">Slaughterhouse-Five</a> </div> <div class="gr_custom_author_1318614690"> by <a href="http://www.goodreads.com/author/show/2778055.Kurt_Vonnegut">Kurt Vonnegut</a> </div> </div> <div class="gr_custom_each_container_1318614690"> <div class="gr_custom_book_container_1318614690"> <a href="http://www.goodreads.com/review/show/202292969?utm_medium=api&utm_source=custom_widget" title="Of Mice and Men"><img alt="Of Mice and Men" border="0" src="http://photo.goodreads.com/books/1309211906s/890.jpg" /></a> </div> <div class="gr_custom_rating_1318614690"> <img alt="3 of 5 stars" height="15" src="http://d16kthk4voxb3t.cloudfront.net/images/layout/stars/red_star_3_of_5.png?1318545374" title="3 of 5 stars, liked it" width="75" /> </div> <div class="gr_custom_title_1318614690"> <a href="http://www.goodreads.com/review/show/202292969?utm_medium=api&utm_source=custom_widget">Of Mice and Men</a> </div> <div class="gr_custom_author_1318614690"> by <a href="http://www.goodreads.com/author/show/585.John_Steinbeck">John Steinbeck</a> </div> </div> <div class="gr_custom_each_container_1318614690"> <div class="gr_custom_book_container_1318614690"> <a href="http://www.goodreads.com/review/show/202292999?utm_medium=api&utm_source=custom_widget" title="Lord of the Flies"><img alt="Lord of the Flies" border="0" src="http://photo.goodreads.com/books/1165637417s/7624.jpg" /></a> </div> <div class="gr_custom_rating_1318614690"> <img alt="4 of 5 stars" height="15" src="http://d2owxupnsl35mn.cloudfront.net/images/layout/stars/red_star_4_of_5.png?1318545374" title="4 of 5 stars, really liked it" width="75" /> </div> <div class="gr_custom_title_1318614690"> <a href="http://www.goodreads.com/review/show/202292999?utm_medium=api&utm_source=custom_widget">Lord of the Flies</a> </div> <div class="gr_custom_author_1318614690"> by <a href="http://www.goodreads.com/author/show/306.William_Golding">William Golding</a> </div> </div> <br style="clear: both"/> <center> <a href="http://www.goodreads.com/"><img src="http://www.goodreads.com/images/widget/widget_logo.gif" alt="goodreads.com" style="border:0;" /></a> </center> <noscript> Share <a href="http://www.goodreads.com">book reviews</a> and ratings with Kevin, and even join a <a href="http://www.goodreads.com/group/">book club</a> on Goodreads. </noscript> </div> </div> <script src="http://www.goodreads.com/review/custom_widget/6131699.Kevin's%20bookshelf:%20read?cover_position=left&cover_size=small&num_books=6&order=a&shelf=read&show_author=1&show_cover=1&show_rating=1&show_review=1&show_tags=1&show_title=1&sort=date_added&widget_bg_color=FFFFFF&widget_bg_transparent=&widget_border_width=1&widget_id=1318614690&widget_text_color=000000&widget_title_size=medium&widget_width=medium" type="text/javascript" charset="utf-8"></script> Hi. I have an interactive house on my website with an image map that different areas link to pages when clicked on. A short title when mouse hovers over. I want to make this look better, better display of text when mouse hovers over, and textbox below image that gives a descrpition of the area selected. Does anyone have a simple way I could do this? I am using wordpress. Thanks, James Hi gurus, I am developing an application in which I am using a client validation library called "livevalidation". When you attach with the input control it shows a message infront of the text box if you leave it empty. But I want to modify it and want to show a image (cross) infront of the text box and message below text box. Here is the CSS file and html file. ------------------------------------ Code: /********************************* LiveValidation *************************************/ .LV_valid { color:#00CC00; } .LV_invalid { color:#CC0000; } .LV_validation_message { clear: both; text-indent: 166px; height: 22px; line-height: 22px; font-size: 11px; font-weight: bold; } .LV_valid_field, input.LV_valid_field:hover, input.LV_valid_field:active, textarea.LV_valid_field:hover, textarea.LV_valid_field:active, .fieldWithErrors input.LV_valid_field, .fieldWithErrors textarea.LV_valid_field { border: 1px solid #00CC00; } .LV_invalid_field, input.LV_invalid_field:hover, input.LV_invalid_field:active, textarea.LV_invalid_field:hover, textarea.LV_invalid_field:active, .fieldWithErrors input.LV_invalid_field, .fieldWithErrors textarea.LV_invalid_field { border: 1px solid #CC0000; } HTML ------ Code: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="livevalidation.js" type="text/javascript"></script> <link href="StyleSheet.css" rel="stylesheet" type="text/css" /> </head> <body> <form id="create_account" action=""> Say hello: <input id="sayHello" type="text" /> <script type="text/javascript"> var sayHello = new LiveValidation('sayHello', { validMessage: 'Hey there!', wait: 500 }); sayHello.add(Validate.Presence, { failureMessage: "Don't just ignore me, I wanna be your friend!" }); </script> </form> </body> </html> For livevalidation javascript (.js) i cannot paste here as its quite big and forums is not allowing me paste it so kindly get it from here which I need to modify. here is the link. ---------------- http://livevalidation.com/javascript..._standalone.js In the above file there is a function called "createMessageSpan" I've tried to modify it as I am sure this is the function which needs to be modified but how to do it that i dont know as i am not a java specialist. Please help I would really appreciate. Josh Hello, I am using the following javascript breadcumb script (found here http://www.javascriptsource.com/navi...eadcrumbs.html ) It works perfectly, except I'm trying to figure out how to remove and replace the "dash" ( - ) character with a space? Code: function breadcrumbs() { sURL = new String; bits = new Object; var x = 0; var stop = 0; var output = "<div class=topnav><a href=/>Home</a> > "; sURL = location.href; sURL = sURL.slice(8,sURL.length); chunkStart = sURL.indexOf("/"); sURL = sURL.slice(chunkStart+1,sURL.length) while(!stop){ chunkStart = sURL.indexOf("/"); if (chunkStart != -1){ bits[x] = sURL.slice(0,chunkStart) sURL = sURL.slice(chunkStart+1,sURL.length); } else { stop = 1; } x++; } for(var i in bits){ output += "<a href=\""; for(y=1;y<x-i;y++){ output += "../"; } output += bits[i] + "/\">" + bits[i] + "</a> > "; } document.write(output + document.title); document.write("</div>"); } Any help would be greatly appreciated. Thank you! In my previous post, I asked how to create a function that would allow me to add to or subtract from a maxvalue, and thankfully I got help regarding that. However, something's got me stumped for the past few weeks that I still can't resolve... This is the relevant code: Code: <html> <head> <script type="text/javascript" language="Javascript"> function chgAdv(btn) { var form = btn.form; var newqty = parseInt(btn.value); var maxqty = form.maxqty; var maxadv = form.maxadv; if (eval("btn.checked") == true && parseInt(maxadv.value) + newqty <= 15) { var newmax = parseInt(maxqty.value) - newqty; var newadv = parseInt(maxadv.value) + newqty; } else if (eval("btn.checked") == false && parseInt(maxadv.value) - newqty >= 0) { var newmax = parseInt(maxqty.value) + newqty; var newadv = parseInt(maxadv.value) - newqty; } else { var newmax = parseInt(maxqty.value); var newadv = parseInt(maxadv.value); } if ( newadv >= 0 && newmax >= 0) { maxqty.value = newmax; maxadv.value = newadv; } } function chgDis(btn) { var form = btn.form; var newqty = parseInt(btn.value); var maxqty = form.maxqty; var maxdis = form.maxdis; if (eval("btn.checked") == true && parseInt(maxdis.value) + newqty <= 10) { var newmax = parseInt(maxqty.value) + newqty; var newdis = parseInt(maxdis.value) + newqty; } else if (eval("btn.checked") == false && parseInt(maxdis.value) - newqty >= 0) { var newmax = parseInt(maxqty.value) - newqty; var newdis = parseInt(maxdis.value) - newqty; } else { var newmax = parseInt(maxqty.value); var newdis = parseInt(maxdis.value); } if (newdis >= 0 && newmax >= 0) { maxqty.value = newmax; maxdis.value = newdis; } } </script> <link rel="stylesheet" type="text/css" href="styles.css"> </head> <body> <form name="f1"> <b>Advantages</b> (<input type="text" class="RO" name="maxadv" value="0" />)<br /> <input type="checkbox" class="RO" name="Absolute Direction" onclick="chgAdv(this);" value="2" />Absolute Direction<br /> <input type="checkbox" class="RO" name="Allies" onclick="chgAdv(this);" value="3" />Allies<br /> <hr> <b>Disadvantages</b> (<input type="text" class="RO" name="maxdis" value="0" />)<br /> <input type="checkbox" class="RO" name="Antisocial" onclick="chgDis(this);" value="2" />Antisocial<br /> <input type="checkbox" class="RO" name="Ascetic" onclick="chgDis(this);" value="4" />Ascetic<br /> max quantity: <input type="text" readonly class="RO" name="maxqty" value="40" /> </form> </body> </html> styles.css is simply: Code: input.RO { border: none; width: 40px; text-align: center; } As it stands, it works as long as the total value is less than or equal to the limit (for advantages it's 15, for disadvantages it's 10). However, the moment it goes past the limit -- for instance, if you change Antisocial's value from 2 to 7, or if you add several additional checkboxes with any values -- the whole thing starts going crazy; specifically, maxvalue doesn't revert to 40 when the all the checkboxes are unchecked. What I'd want to happen is that the user cannot select or apply advantages or disadvantages if the maximum advantage is greater than 15 or the maximum disadvantages is greater than 10. I'm thinking that a button for adding disadvantage points to/subtracting advantage points from the maxvalue (that becomes disabled if the user goes past his limit on advantages/disadvantages) is useful at this point, but I'm really stumped on the implementation of the idea. An alternate idea of mine is that all other advantage/disadvantage checkboxes would become disabled if their value is greater than the remaining number of points, but I don't know how that is possible either. Any and all help is greatly appreciated. Hi all, please help... There is a small, but very usability script - Multiple Dynamic Combo Boxes by Elviro Mirko (http://www.javascriptkit.com/script/...plecombo.shtml). Since there are many versions of this script. One of them, which I did. Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title> New Document </title> <script type="text/javascript"> <!-- /* *** Multiple dynamic combo boxes *** by Mirko Elviro, 9 Mar 2005 *** Script featured and available on JavaScript Kit (http://www.javascriptkit.com) *** ***Please do not remove this comment */ // This script supports an unlimited number of linked combo boxed // Their id must be "combo_0", "combo_1", "combo_2" etc. // Here you have to put the data that will fill the combo boxes // ie. data_2_1 will be the first option in the second combo box // when the first combo box has the second option selected // first combo box // data_1 = new Option("All Models", "#"); data_2 = new Option("Model 1", "#"); data_3 = new Option("Model 2", "#"); // second combo box // //All data_1_1 = new Option("All Types", "#"); data_1_2 = new Option("Type 1", "#"); data_1_3 = new Option("Type 2", "#"); //Model 1 data_2_1 = new Option("All Types", "#"); data_2_2 = new Option("Type 1", "#"); data_2_3 = new Option("Type 2", "#"); //Model 2 data_3_1 = new Option("All Types", "#"); data_3_2 = new Option("Type 1", "#"); data_3_3 = new Option("Type 2", "#"); // third combo box // //All Models data_1_1_1 = new Option("All Sizes", "#"); data_1_1_2 = new Option("Size 1", "#"); data_1_1_3 = new Option("Size 2", "#"); data_1_2_1 = new Option("All Sizes", "#"); data_1_2_2 = new Option("Size 1", "#"); data_1_2_3 = new Option("Size 2", "#"); data_1_3_1 = new Option("All Sizes", "#"); data_1_3_2 = new Option("Size 1", "#"); data_1_3_3 = new Option("Size 2", "#"); //Model 1 data_2_1_1 = new Option("All Sizes", "#"); data_2_1_2 = new Option("Size 1", "#"); data_2_1_3 = new Option("Size 2", "#"); data_2_2_1 = new Option("All Sizes", "#"); data_2_2_2 = new Option("Size 1", "#"); data_2_2_3 = new Option("Size 2", "#"); data_2_3_1 = new Option("All Sizes", "#"); data_2_3_2 = new Option("Size 1", "#"); data_2_3_3 = new Option("Size 2", "#"); //Model 2 data_3_1_1 = new Option("All Sizes", "#"); data_3_1_2 = new Option("Size 1", "#"); data_3_1_3 = new Option("Size 2", "#"); data_3_2_1 = new Option("All Sizes", "#"); data_3_2_2 = new Option("Size 1", "#"); data_3_2_3 = new Option("Size 2", "#"); data_3_3_1 = new Option("All Sizes", "#"); data_3_3_2 = new Option("Size 1", "#"); data_3_3_3 = new Option("Size 2", "#"); // fourth combo box // //All Models data_1_1_1_1 = new Option("All color","http://special.link"); data_1_1_1_2 = new Option("Color 1","http://special.link"); data_1_1_1_3 = new Option("Color 2","http://special.link"); data_1_1_2_1 = new Option("All color","http://special.link"); data_1_1_2_2 = new Option("Color 1","http://special.link"); data_1_1_2_3 = new Option("Color 2","http://special.link"); data_1_1_3_1 = new Option("All color","http://special.link"); data_1_1_3_2 = new Option("Color 1","http://special.link"); data_1_1_3_3 = new Option("Color 2","http://special.link"); data_1_2_1_1 = new Option("All color","http://special.link"); data_1_2_1_2 = new Option("Color 1","http://special.link"); data_1_2_1_3 = new Option("Color 2","http://special.link"); data_1_2_2_1 = new Option("All color","http://special.link"); data_1_2_2_2 = new Option("Color 1","http://special.link"); data_1_2_2_3 = new Option("Color 2","http://special.link"); data_1_2_3_1 = new Option("All color","http://special.link"); data_1_2_3_2 = new Option("Color 1","http://special.link"); data_1_2_3_3 = new Option("Color 2","http://special.link"); data_1_3_1_1 = new Option("All color","http://special.link"); data_1_3_1_2 = new Option("Color 1","http://special.link"); data_1_3_1_3 = new Option("Color 2","http://special.link"); data_1_3_2_1 = new Option("All color","http://special.link"); data_1_3_2_2 = new Option("Color 1","http://special.link"); data_1_3_2_3 = new Option("Color 2","http://special.link"); data_1_3_3_1 = new Option("All color","http://special.link"); data_1_3_3_2 = new Option("Color 1","http://special.link"); data_1_3_3_3 = new Option("Color 2","http://special.link"); //All Model 1 data_2_1_1_1 = new Option("All color","http://special.link"); data_2_1_1_2 = new Option("Color 1","http://special.link"); data_2_1_1_3 = new Option("Color 2","http://special.link"); data_2_1_2_1 = new Option("All color","http://special.link"); data_2_1_2_2 = new Option("Color 1","http://special.link"); data_2_1_2_3 = new Option("Color 2","http://special.link"); data_2_1_3_1 = new Option("All color","http://special.link"); data_2_1_3_2 = new Option("Color 1","http://special.link"); data_2_1_3_3 = new Option("Color 2","http://special.link"); data_2_2_1_1 = new Option("All color","http://special.link"); data_2_2_1_2 = new Option("Color 1","http://special.link"); data_2_2_1_3 = new Option("Color 2","http://special.link"); data_2_2_2_1 = new Option("All color","http://special.link"); data_2_2_2_2 = new Option("Color 1","http://special.link"); data_2_2_2_3 = new Option("Color 2","http://special.link"); data_2_2_3_1 = new Option("All color","http://special.link"); data_2_2_3_2 = new Option("Color 1","http://special.link"); data_2_2_3_3 = new Option("Color 2","http://special.link"); data_2_3_1_1 = new Option("All color","http://special.link"); data_2_3_1_2 = new Option("Color 1","http://special.link"); data_2_3_1_3 = new Option("Color 2","http://special.link"); data_2_3_2_1 = new Option("All color","http://special.link"); data_2_3_2_2 = new Option("Color 1","http://special.link"); data_2_3_2_3 = new Option("Color 2","http://special.link"); data_2_3_3_1 = new Option("All color","http://special.link"); data_2_3_3_2 = new Option("Color 1","http://special.link"); data_2_3_3_3 = new Option("Color 2","http://special.link"); //All Model 2 data_3_1_1_1 = new Option("All color","http://special.link"); data_3_1_1_2 = new Option("Color 1","http://special.link"); data_3_1_1_3 = new Option("Color 2","http://special.link"); data_3_1_2_1 = new Option("All color","http://special.link"); data_3_1_2_2 = new Option("Color 1","http://special.link"); data_3_1_2_3 = new Option("Color 2","http://special.link"); data_3_1_3_1 = new Option("All color","http://special.link"); data_3_1_3_2 = new Option("Color 1","http://special.link"); data_3_1_3_3 = new Option("Color 2","http://special.link"); data_3_2_1_1 = new Option("All color","http://special.link"); data_3_2_1_2 = new Option("Color 1","http://special.link"); data_3_2_1_3 = new Option("Color 2","http://special.link"); data_3_2_2_1 = new Option("All color","http://special.link"); data_3_2_2_2 = new Option("Color 1","http://special.link"); data_3_2_2_3 = new Option("Color 2","http://special.link"); data_3_2_3_1 = new Option("All color","http://special.link"); data_3_2_3_2 = new Option("Color 1","http://special.link"); data_3_2_3_3 = new Option("Color 2","http://special.link"); data_3_3_1_1 = new Option("All color","http://special.link"); data_3_3_1_2 = new Option("Color 1","http://special.link"); data_3_3_1_3 = new Option("Color 2","http://special.link"); data_3_3_2_1 = new Option("All color","http://special.link"); data_3_3_2_2 = new Option("Color 1","http://special.link"); data_3_3_2_3 = new Option("Color 2","http://special.link"); data_3_3_3_1 = new Option("All color","http://special.link"); data_3_3_3_2 = new Option("Color 1","http://special.link"); data_3_3_3_3 = new Option("Color 2","http://special.link"); // other parameters displaywhenempty=""; valuewhenempty=-1; displaywhennotempty="-select-"; valuewhennotempty=0; function change(currentbox) { numb = currentbox.id.split("_"); currentbox = numb[1]; i=parseInt(currentbox)+1; // I empty all combo boxes following the current one while (document.getElementById("combo_"+i)) { son = document.getElementById("combo_"+i); // I empty all options except the first one (it isn't allowed) for (m=son.options.length-1; m>0; m--) son.options[m]=null; // I reset the first option son.options[0]=new Option(displaywhenempty,valuewhenempty); i++; } // now I create the string with the "base" name ("stringa"), ie. "data_1_0" // to which I'll add _0,_1,_2,_3 etc to obtain the name of the combo box to fill stringa='data'; i=0; while (document.getElementById("combo_"+i)) { stringa=stringa+'_'+document.getElementById("combo_"+i).selectedIndex; if (i==currentbox) break; i++; } // filling the "son" combo (if exists) following=parseInt(currentbox)+1; if (document.getElementById("combo_"+following)) { son = document.getElementById("combo_"+following); stringa=stringa+"_"; i=0; while ((eval("typeof("+stringa+i+")!='undefined'")) || (i==0)) { // if there are no options, I empty the first option of the "son" combo // otherwise I put "-select-" in it if ((i==0) && eval("typeof("+stringa+"0)=='undefined'")) if (eval("typeof("+stringa+"1)=='undefined'")) son.options[0]=new Option(displaywhenempty,valuewhenempty); else son.options[0]=new Option(displaywhennotempty,valuewhennotempty); else son.options[i]=new Option(eval(stringa+i+".text"),eval(stringa+i+".value")); i++; } //son.focus() i=1; combostatus=''; cstatus=stringa.split("_"); while (cstatus[i]) { combostatus=combostatus+cstatus[i]; i++; } return combostatus; } } function go(elementName){ var newUrl=document.forms[0].elements[elementName].options[document.forms[0].elements[elementName].selectedIndex].value; if(newUrl.indexOf("http://")>=0){//rudamentary url checker! So don't go to a blank page if select box not populated. location.href=newUrl; } } //--> </script> </head> <body> <form> Model: <br /> <select name="combo0" id="combo_0" onChange="change(this);" style="width:200px;"> <option value="value1">-select-</option> <option value="value2">All Models</option> <option value="value3">Model 1</option> <option value="value4">Model 2</option> </select> <br /> Type: <br /> <select name="combo1" id="combo_1" onChange="change(this)" style="width:200px;"> <option value="value1"> </option> </select> <br /> Size: <br /> <select name="combo2" id="combo_2" onChange="change(this);" style="width:200px;"> <option value="value1"> </option> </select> <br /> Color: <br /> <select name="combo3" id="combo_3" onChange="change(this);" style="width:200px;"> <option value="value1"> </option> <br /> <input type="button" value="Go" onclick="go('combo3')"> <!-- could be changed for onchange event handler on select box --> </select> </form> <p align="center"><font face="arial" size="-2">This free script provided by</font><br> <font face="arial, helvetica" size="-2"><a href="http://javascriptkit.com">JavaScript Kit</a></font></p> </body> </html> But I need to when you first start the script immediately showed the first value and its associated down decaying values without - select - immediately show combo first values All Models All Types All Sizes All Сolor (and after next for various behaviors the user's manipulation choice) **Or are there any other JS solutions that satisfy my request I would be grateful for any aid.... Hello, I am very new to javascript and most programming in general, but I am trying to make a simple game with a ball and paddle. The catch is the user inputs the height, width and speed of the ball, then when the start button is hit, the program runs... I was successfully able to make the ball bounce in a preset box (it was 500x500) but I am struggling to get the code to work when the user types in the values the ball either goes crazy or does not work. I have tried many things, but nothing has worked. the code I included is my most recent attempt. I am not asking for you guys to do the whole game for me, I would just like to know the solution to why my code is not working and any suggestions the ball is 15x15px btw Thanks, thejsnoob Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> <style type="text/css"> .button{height: 170px}; <!-- img { position: absolute; top: 300px; left: -50px; z-index::+1;} --> </style> </head> <body> <img src="ball.png" alt=""> <form name = "form1"> <table border = "1"> <tr> <td> WIDTH: </td> <td> <input type="text" id = "usrWidth"/> </td> <td rowspan="3" align="center" valign="middle"> <input type="button" class="button" value="START" onclick="moveImg()"/> </td> </tr> <tr> <td> HEIGHT: </td> <td> <input type="text" id = "usrHeight"/> </td> </tr> <tr> <td> SPEED: </td> <td> <input type="text"/> </td> </tr> </table> </form> <tr> <td></td> </tr> </table> <script language="JavaScript" type="text/javascript"> <!-- var xDir = 1; var yDir = -1; var left; var top; var check = 1; function moveImg() // clicks the button { var userWidth = document.form1.usrWidth.value; var userHeight = document.form1.usrHeight.value; if ( check == 1 ){ left=Math.floor(Math.random()* (userWidth + 1)); top=(Math.floor(Math.random()* (userHeight + 1)) + 220); document.images[0].style.left = left + "px"; document.images[0].style.top = top +"px"; check = 0; } document.body.appendChild(rectangle(userWidth,userHeight)) left += xDir; top += yDir; if ((top < 220) || (top > userHeight - 15)) yDir *= -1; if (left > (userWidth - 15) || (left < 0)) xDir *= -1; setTimeout(moveImg, 10); } function rectangle(w,h) { var rect = document.createElement("div"); var style = rect.style; style.width = w +"px"; style.height = h +"px"; style.left = "0px"; style.top = "220px"; // fixed style.position = "absolute"; style.borderStyle = "solid" style.borderWidth = 1; return rect } //document.body.appendChild( rectangle(500,500,0,220,"","red") ) //--> </script> </body> </html> Hi, I am hoping I just need to be pointed in the right direction with this. I have Page1. When Page1 body onloads it uses Ajax to call PartA Within PartA I have a message board so members can write messages which will be sent to my database in PartA[1] and immediately posted for view on to PartA[2]. As I want to have my request to the server updating regularly I want to have PartA[2] on a timed loop to refresh - I do not need the content of PartA[1] to refresh. So the order of events would look like this: Page1 | onload call | v PartA / \ V V PartA[1] PartA[2] (loads once) (constantly refreshes) What I am not sure about is that I have <body> and <head> attributes in Page1 only. I have already used my body onload to call PartA (and can't use it to call PartA[2] before PartA has loaded anyway). I do not want the user to have to click a button or do anything to call up PartA[2]. So my question is how would I get PartA[2] to automatically load within PartA? I hope I have made this clear, but if I haven't let me know and I will try again. I'm sorry I don't have code for this one. I'm making a fansite for a game called RuneScape and I'm a bit stuck on this part. What I need for my website is, a page that will have the prices (min, middle, and max) of things from this or other items, which will be chosen later on. Here are two example sites that I am wanting to ... do the same thing as them. First Example Second Example I'd really appreciate any information you guys are willing to give. Thanks. Hello guys, Is there any way I can get the number of 'CPBucks' from this piece of HTML, It's currently at 1 but it will change. Code: <div class="user-info"> <img src="http://illiweb.com/fa/punbb/online.png" id="i_icon_online" alt="Online" title="Online"><br> <span style="white-space:nowrap;"><span style="color:##66666;">Posts</span>: </span>2<br> <span style="white-space:nowrap;"><span style="color:##66666;">CPBucks</span>: </span>1<br> <span style="white-space:nowrap;"><span style="color:##66666;">Join date</span>: </span>2011-10-11<br> </div> Thanks Hey everybody, what regular expression do i have to use to get the 2 last elements of a user agent? eg in firefox how can i get : Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20100101 Firefox/7.0.1 Firefox & 7.01 ? thanks! Hello everyone I would like to understand how can I do a drop down many exactly as the www.oracle.com webpage. The idea is to build some kind of menu in my web project. I know that this could be a noob question for some, thank you anyeway for any help in advanced. Renzo ++ Hi everyone! Firstly, im a beginner in Javascript, totally noobie. Much why this is posted! I have found this site: http://www.forswor.com/index.php/data-apis/ And I want to use this to post the server status on my forum/website. How exactly do I do that? I know there are examples and such and I have read and read on that page but I cannot figure out how to do this. I cant just paste: <script type="text/javascript" src="http://www.forswor.com/forswor_services/prod/serverwidget/getSWTORStatusjs.php"> </script> How would I get this to show the information of say for example Bloodworthy server and in text? I tried adding the line document.write(forswor_server_name);, but didnt show up anything - stupid as I am obviously I have no clue what im doing. I can manage html\css and some php but this is new for me, hehe. Thank you so much for reading an idiots post! Most regards, me. I am currently working on a project that requires pretty large bits of jQuery (atleast for me) and once I get this function working I can solve more required functions but I have problems getting this to work. Basically what im trying to do is, when a link is clicked (within a certain div) it reads out the class of that link and searches within XML or JSON for the title and then finds the description within that record. I hope someone is able to point to the right direction, Thanks in advance, Mehk. Is it possible to get a entire system configuration information including RAM Size,Type,HD Size,Processor details using JavaScript Or any other Scripting Language. Please Help Me In Getting This. . . Can anyone let me know how can I get the href info dynamically I have 2 different webistes, just want to show those website urls dynamically <html> <body> <a href="http://www.yahoo.com" target="_blank">YAHOO</a> <a href="http://www.Google.com" target="_blank">Google</a> <script type="text/javascript"> document.write(href url of yahoo); document.write('href url of google); </script> </body> </html> thanks for help in advance |