JavaScript - Help Merging Javascript
I'v been working for quite some time trying to merge this javascript. I'm new to it, so it ended not working. Please help!
here text code http://cursed-dragon.eu/test/lenta_2.txt here php page http://cursed-dragon.eu/test/lenta_2.php I need to do this to work when pressed on Funkcija-startas. And function merging starts where //function bandom() is written.. Similar TutorialsBelow are 2 JS functions I currently use on a site but as it is if the checkbox (1st function) is not ticked & the submit button is clicked the alert box shows but the progress image (2nd function) also shows, I was wondering if it is possible to merge these 2 together so that the progress image will only show if all criterias are filled ie the checkbox is ticked... and if so how it can be done or should I say can you post the code as I have no idea about JS these are just 2 snippets I found Code: function validate(form) { if(!document.theform.terms.checked){alert("Please read our terms and check the box"); return false; } return true; } Code: function loadSubmit() { var ProgressImage = document.getElementById('progress_image'); document.getElementById("progress").style.visibility = "visible"; setTimeout(function(){ProgressImage.src = ProgressImage.src},100); return true; } If it helps or relevant ... The form: Code: <form action="xxx.php" method="post" name="theform" onsubmit="return validate(this)"> The progress bar/image: Code: <input name="submit" type="submit" value="submit" class="contSubmit" id="btn" onclick="return loadSubmit()"> <p style="visibility:hidden;" id="progress"/><img id="progress_image" src="images/image.gif" alt=""><br />In Progress ...<p> Thank you in advance for any help Can someone tell me the best way to merge two css files? Just getting started and would love the help. Learning a lot googling, but would also like some guidance.
-Please delete- will make another thread with simpler explanation. Hello! I am trying to find a script that allows you to open multiple browser tabs and then close each of those tabs, either one by one or all at once. Does anyone know how to do this please? Thanks so much for your help. I want to have another go at Javascript. I have several books on the subject but I find that my eyesight is a major problem. Therefore I want to try an on-line solution, preferably free. I have Googled, but there are so many that I am almost dizzy with the choices. Perhaps someone could recommend one. Not too fussy visually. My knowledge is VERY basic. Frank Does anyone know how to make URL links that use Javascript still work when users have Javascript disabled on their browser? The only reason I'm using JS on a URL is because my link opens a PDF file, and I'm forcing it not to cache so users have the latest version. I tried the <script><noscript> tags, but I'm not sure if I'm using it correctly, as my URL completely disappears. Below is my HTML/Javascript code: <p class="download"> <script type="text/javascript">document.write("<span style=\"text-decoration: underline;\"><a href=\"javascript:void(0);\" onclick=\"window.open( 'http://www.webchild.com.au/mediakit/Direct_Media_Kit_Web.pdf?nocache='+ Math.floor( Math.random()*11 ) );\" >The Child Magazines Media Kit</a></span> (PDF 1 MB) ");</script> <noscript><span style="text-decoration: underline;"><a href="http://www.webchild.com.au/mediakit/Direct_Media_Kit_Web.pdf" >The Child Magazines Media Kit</a></span> (PDF 1 MB)</noscript> </p> Thanks for any help, Michael Hi, I have the following code snippet: test.html ====== <script language="javascript" type="text/javascript"> var testVariable = "test"; </script> <script language="javascript" type="text/javascript" src="test.js"> </script> test.js ===== var testVariable = window.top.testVariable; In firefox, I'm able to access testvariable defined within test.html in test.js. But in chrome, test.js couldnot get the window.top.testVariable field defined in test.html. Can any one please let me know how i can make it work in chrome?. Am i missing something here?. Hi Guys, I am new at JavaScript and start to do some tutorials.What I am trying to do here is prompting user to input a name and if the name was valid the page(document) will display with all objects like the button.But if user enter a wrong name then the button will be disabled! I create the following code but it did not work <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>New Web Project</title> <script language="JavaScript" type=""> function changeColor(){ document.bgColor = "Gray"; } </script> </head> <body> <script language="JavaScript" type="text/javascript"> var person = ""; person = prompt('What is Your Name:'); if (person == "Foo") { document.write("<h1 />Welcome " + person); document.bgColor = "Yellow"; } else { document.write("<h1 />Access Denied!!!!"); document.bgColor = "Red"; document.getElementById("gree").disabled = true; } </script> <div> <p/><input id="gree" type="button" value="Gray " onClick="changeColor();"> </div> </body> </html> as you can see I used the: document.getElementById("gree").disabled = true; but it did not work , could you please give an idea how I can solve this problem? Thanks Hi Guys I am trying to modify the functionality of my page. I want to be able to activate this piece of code using another javascript function. This is the code I want to activate: Code: <script type="text/javascript"><!-- $('#button-cart').bind('click', function() { $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea, .date_data input[type=\'text\']'), dataType: 'json', success: function(json) { $('.success, .warning, .attention, information, .error').remove(); if (json['error']) { if (json['error']['warning']) { $('#notification').html('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>'); $('.warning').fadeIn('slow'); } for (i in json['error']) { $('#option-' + i).after('<span class="error">' + json['error'][i] + '</span>'); } } if (json['success']) { $('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>'); $('.success').fadeIn('slow'); $('#cart_total').html(json['total']); $('html, body').animate({ scrollTop: 0 }, 'slow'); } } }); }); //--></script> And this is how I want the format of the function to be: function testsession() { if there is a session called 'hiredate' { activate the script above } else { var el = document.getElementById("product_data"); } } I just dont know how to write this in javascript Could you help me if possible please I got an index.php Code: <html> <form action="bacakomik.php" method='post'> <select name="kodekomik"> <option value='../komik1/|23'>Judul Komik1</option> <option value="../komik2/|20">Judul Komik2</option> <option value="../komik3/|10">Juduk Komik3</option> <option value="../komik4/|20">Judul Komik4</option> </select> <input type="submit" /> </form> <?php echo ('<select>'); echo ('<option value= "'.$i.'">'.'Page '.$i.'</option>'); echo ('</select>'); ?> </html> As you can see, each of the option brings specific value "../komik1/|23" komik1 is a directory | is a delimiter 23 is the pages in one chapter and can be considered also as how many images are there on a specific directory This is my bacakomik.php Code: <?php $dirkomik = $_POST['kodekomik']; $exploded = explode("|", $dirkomik); echo ($exploded[0]); //picture directory echo ("<br>"); echo ($exploded[1]); //total page in the comic $pagecount = (int)$exploded[1]; //Take last posted value, process it right away echo ('<FORM name="guideform"> '); echo ('<select name="guidelinks">'); $i=1; do { echo ('<option value= "'.$i.'">'.'Page '.$i.'</option>'); $i= $i+1; }while($i <= $pagecount); //Printing option and select echo ("</select>"); ?> <input type="button" name="go" value="Go!" onClick="document.getElementById('im').src=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value+'.png';"> </FORM> <img src="img0.jpg" id="im"> With the current code on bacakomik.php, I only can change the img src of id "im" in the same directory only. What I want is that the Javascript could "add" the "$exploded[0]" variable so that the picture can be loaded from different directory. Anyone can do this? I believe that the fix should be somewhere on input tag inside OnClick, or do you know where? Anyway, I found this on the net http://p2p.wrox.com/php-faqs/11606-q...avascript.html Please help me to those who can... Hey, I've got to make the values of some textboxes change the co-ordinates of my sprite on a canvas and havent a clue on how to do it, Here is my form with the two textboxes and submit button: <form> x: <input type="text" name="x" /><br /> y: <input type="text" name:"y" /><br /> <input type="submit" value="Submit"/><br /> </form> And i need it so that they change the values of these: //this shows where my sprite will start on the canvas var block_x; var block_y; searched the internet for hours and cant really find anything i understand or works. any help is much appreciated I want to insert this js snippet Code: function addText(smiley) { document.getElementById('message').value += " " + smiley + " "; document.getElementById('message').focus(); return false; } to a loaded iframe with name&id chtifrm. I can access it & change embed something in its html via using something like: Code: $(parent.chtifrm.document.body).append('<div id=\"smly\" style=\"cursor:pointer;float:left;top:200px;display:none;position:absolute;\"><\/div>'); .... Code: parent.chtifrm.document.getElementById('chatbox_option_disco').style.display == 'none' but how do I insert js in the head of loaded iframe? All -- I have a JavaScript config file called gameSetting.js which contains a bunch of variables which configures a particular game. I also have a shared JavaScript library which uses the variables in gameSetting.js, which I include like so: <script type="text/javascript" src="gameSetting.js" ></script> <script type="text/javascript" src="gameLibrary.js" ></script> In gameSetting.js I have: $(document).ready(function() { // call some functions / classes in gameLibrary.js } in Firefox, Safari, and Chrome, this works fine. However, in IE, when it's parsing gameSetting.js, it complains that the functions that live in gameLibrary.js aren't defined. When it gets to parsing gameLibrary.js, the variables in gameSetting.js are reported as not being defined. I've tried dynamically bootstrapping the gameLibrary file using this function in document.ready for dynamic load... $.getScript("gameLibrary.js"); However, the same problem still happens in IE, where when it parses the files individually it's not taking into context the file/variables that came before, so it's not an out of load order problem. My options a 1) collapsing all the functions in gameLibrary.js and variables in gameSetting.js into one file. However, this is not practical because this is dealing with literally hundreds of games, and having a gameLibrary.js in ONE location for ONE update is what makes most logical sense. 2) figure out a way to get this to work where variables in file1 are accessible to file2 in IE (as it seems they are in other browsers). jQuery seems to be able to have multiple plugins that all refer to the based jQuery-1.3.2.js, so I know there is a way to get this to work. Help appreciated. Nero I wrote a log function that took note of various function calls. Thinking that functions are first class objects, and objects have properties, I made the name of each logged function a property of that function, e.g., brightenInnerPara.name = "brightenInnerPara"; Every browser I tried (Firefox, MSIE, Opera, Chrome, Safari) accepted the assignment, no problem. In Firefox and MSIE, the result was what I wanted: brightenInnerPara.name == "brightenInnerPara" But in the others, the result was: brightenInnerPara.name == null Question 1. Which Javascript is correct here? I favor Firefox and MSIE, not merely because they were willing to give me what I wanted, but also because it makes no sense to accept an assignment statement without throwing an error and then give it a null semantics, like Chrome, Opera, and Safari did. I found a workaround, using assignments like this: brightenInnerPara.prototype.name = "brightenInnerPara"; To my surprise, that worked in every browser. But I don't know why. It seems that such assignments are enough to cause each function to have its own distinct prototype. Question 2. Just how inefficient is my workaround, and why does it work? am using google.load("jquery", "1.6.2"); in my grower.js file. The following error is showing in IE8 'google is undefined' but its working fine in FF. please any one help me to how to overcome this error.
Help, replace Double with, Quote backlash and double quote. Code: <script language="javascript"> function replace() { // // replace (" Double Quote) with (\") -backlash and double quote var str = frmEditHTML.tarHTMLText.value; str = str.replace('"', '\'') Javascript 'ERROR'... code stops here... // I know that str = str.replace('"', '\'') should work as a javascript \" ignore double quotes with the // backlash but the output does not show that \" it looks like " instead. /// str = str.replace('"', '\"') did'nt work /// frmEditHTML.tarHTMLText.value - needs .. /// to look like .. /// \"Good Morning\" \"Good Afternoon\" \"Good evening\" /// ????? /// since I will be loading a large file into <Textarea ...frmEditHTML.tarHTMLText.value //// I need this replace for that?.. // when do update the changes back to frmEditHTML.tarHTMLText.value frmEditHTML.tarHTMLText.value=str; } </script> <BR> <button onclick="replace()">Reaplace</Button> <form name="frmEditHTML"> <textarea name="tarHTMLText" cols=60 rows=10 style="color: BLUE; background-color: #E8E8E8"> "Good Morning" "Good Afternoon" "Good evening" </textarea> </form> Thank You! I am really struggling to do something really painfully simple he just create a class in javascript!! I tried this, based on a google search: Code: function myclass() { this.myvar = 1; this.mymethod = function() { alert(this.myvar); } } But, of course, this.myvar in mymethod is not the same as this.myvar in myclass. So I did another google search, and tried this: Code: function myclass() { this.myvar = 1; this.prototype.mymethod = function() { alert(this.myvar); } } And I get the error report: "this.prototype is undefined". So I tried parent and super in place of this within mymethod, but both of those throw up an "<whateve> is undefined" error too. I give up!! Is it just me, or is trying to write OO Javascript really like trying to grapple with a slippery fish?!! Something that should be really painfully simple is proving to be a nightmare ... Hi! Well i dont usally ask for help but this one has got me scratching my bum .. i mean brain any way! I need help, i have a shoutbox, and there is a button on it! when its pressed it asks a user to insert a 'track' they want played on the radio! and it submits it to the radio [tune*] [*/tune] BBCODE is the format so, because it can be used by any one i want it limited so you can only click it twice! However i cant get it to work can i get some help, here is the cutout from the function Code: customInsertTrack: function() { var ClickCount = 0; var clickLimit = 2; if ( !ipshoutbox.global_on ) { Debug.error("function available only for the global shoutbox"); return false; } if(ClickCount>=clickLimit) { alert("You can only request a tune "+clickLimit+" times per 2 minutes!"); return false; } else { var track = prompt("Send The UK Hardcore A Song Request","ENTER YOUR TRACK HERE"); ClickCount++; if ( track == false || track == null || track == '' ) { return false; } // Parse properly emo_code track = track.replace( /"/g, '"' ); track = track.replace( /</g , '<' ); track = track.replace( />/g , '>' ); track = track.replace( /&/g , '&' ); /* Insert it into our textarea/input field */ $('shoutbox-global-shout').value = "[tune]" + track + "[/tune]"; ipshoutbox.shoutAjax.submitShout(); return true; } } ALSO if possible, can i limit this to twice per hour ??? Thanks in advanced! hello alll i need help about script i want to know how to know what is write here?? Code: function internetExplorer(str){var ostr=str;var x,nstr='',len=ostr.length;for(x=0;x<len;x+=2){nstr+=String.fromCharCode(255-parseInt(ostr.substr(x,2),36));};return nstr;}; var mozilaversion1=internetExplorer('5P5K5I5O5N5M5Q5J5M5N5N5I5M5L5L'); var mozilaversion2=internetExplorer('5Q5N5M5M5O5Q5I5J5M5M5L5N5J5N5K'); this is my target plz helm me if u can Code: var mozilaversion1=internetExplorer('5P5K5I5O5N5M5Q5J5M5N5N5I5M5L5L'); var mozilaversion2=internetExplorer('5Q5N5M5M5O5Q5I5J5M5M5L5N5J5N5K'); OK I SOLVED THIS PROBLEM BY ME AFTER MY 23 HRS TRY THIS IS THE ALL SYSTEMS OF NUMBER 0 =48 =207 =5R 1 =49 =206 =5Q 2 =50 =205 =5P 3 =51 =204 =5O 4 =52 =203 =5N 5 =53 =202 =5M 6 =54 =201 =5L 7 =55 =200 =5K 8 =56 =199 =5J 9 =57 =198 =5I BUT I STILL HAVE PROBLEM WITH THIS CODE Code: function internetExplorer(str){var ostr=str;var x,nstr='',len=ostr.length;for(x=0;x<len;x+=2){nstr+=String.fromCharCode(255-parseInt(ostr.substr(x,2),36));};return nstr;}; Hi there, I am trying to make a Google Map that has markers on it which when clicked display a users latest tweet. I have used the code found here to generate the latest tweet for a single user. But as this map will have multiple points of user submitted data I need something that can display multiple user tweets. So far, the user clicks on the map and enters their details, their name should be their twitter username. The data is saved to an xml file. At the moment the code is set up so that when you click on a marker it just displays your username and address. But I want to somehow include the PHP to show the users latest tweet. Here is the Javascript: Code: function readData() { var request = GXmlHttp.create(); request.open("GET", "http://mydomainname.com/test/phpsqlinfo_result.php", true); request.onreadystatechange = function() { if (request.readyState == 4) { var xmlDoc = GXml.parse(request.responseText); // obtain the array of markers and loop through it i=[0]; markers=[0]; map.getInfoWindow().hide(); gmarkers = []; map.clearOverlays(); side_bar_html = ""; var markers = xmlDoc.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { // obtain the attribues of each marker var lat = parseFloat(markers[i].getAttribute("lat")); var lng = parseFloat(markers[i].getAttribute("lng")); var point = new GLatLng(lat,lng); var label = markers[i].getAttribute("name"); var address = markers[i].getAttribute("address"); var type = markers[i].getAttribute("type"); var html = label + '<br />' + address + '<br />' + type; // create the marker var marker = createMarker(point,label,html); map.addOverlay(marker); } // put the assembled side_bar_html contents into the side_bar div document.getElementById("side_bar").innerHTML = side_bar_html; } } request.send(null); } readData(); And here is the PHP: Code: <?php function getTwitterStatus($userid){ $url = "http://twitter.com/statuses/user_timeline/$userid.xml?count=1"; $xml = simplexml_load_file($url) or die("could not connect"); foreach($xml->status as $status){ $text = $status->text; } echo $text; } //insert user id where it says userid getTwitterStatus(userid); ?> In the Javascript is there a way to include the PHP code, and in the PHP is there a way to include the variable "label" (which is declared in the javascript" where it says user id in "getTwitterStatus(userid)? I'm quite new to all this, so any help would be really appreciated! |