JavaScript - The Ajax Part Of This Code Does Not Work
Code:
function dimensions(){ $('.resource-container').css("width",($(window).width() - 306) + 'px'); $('.resource-title').css("width",($(window).width() - 366) + 'px'); $('.resource-container').css("height",($(window).height() - 250) + 'px'); $('.resource-content ul').css("height",($(window).height() - 292) + 'px'); $('.resource-iframe').css("width",($(window).width() - 306) + 'px'); $('.resource-iframe').css("height",($(window).height() - 275) + 'px'); } function resourcego(id){ $.ajax({ url: "http://glynit.co.cc/resource.php?id=" + id + "&item=list&part=name", cache: false, success: function(data){ name = data; $.ajax({ url: "http://glynit.co.cc/resource.php?id=" + id + "&item=list&part=list", cache: false, success: function(data){ list = data; $('.resource-toolbar').html('<div id="resource-title" class="resource-title">' + name + '</div>'); $('.resource-content').html('<div class="resource-list"><ul>' + list + '</ul></div>'); dimensions(); } }); } }); } function viewresource(id,ref){ $.ajax({ url: "http://glynit.co.cc/resource.php?id=" + id + "&content=name", cache: false, success: function(data){ name = data; $('.resource-toolbar').html('<div id="resource-back" class="resource-back" onclick="resourcego(' + ref + ');">Back</div><div id="resource-title" class="resource-title">' + name + '</div><div id="resource-print" class="resource-print">Print</div>'); $('.resource-content').html('<iframe id="resource-iframe" class="resource-iframe" src="http://glynit.co.cc/resource.php?id=' + id + '&content=content"></iframe>'); dimensions(); } }); } $(window).load(function() {dimensions();}); $(window).resize(function() {dimensions();}); The webiste is http://www.glynit.co.cc/ and the login is guest:guest And the page is the resources page and it is the links on the left of that page that do not work. Similar Tutorialshello i need help in deleting a code part, like: table, ul ... the problem is that when i use rss feeds, lot of them add some code parts that i don't need like: <ul class="similar-topics">, and it shows similar topics so, i want to remove this code part from the rss feed i think that i may add a javascript code to the rss template that brings the rss feeds, so as it remove the part i define i hope you help me doing this, even with another idea another idea is to use: http://pipes.yahoo.com i"m sure there is a way to cut parts from the code, but i couldn't get it yet and i'm still trying Regards Hello There, I have form which submitted data by checkbox checked, the checkbox as looks: PHP Code: <input type="checkbox" name="agree" value="1" checked="checked" onclick="document.getElementById('parentTable').className,processForm() = this.checked ? 'vehicleOn' : 'vehicleOff'" /><label for="agree">Agree</label> and the Ajax as following Code: function processForm() { $.ajax({ type: 'POST', url: '<?php echo $send; ?>', data: 'opt1=' + encodeURIComponent($('input[name=\'opt1\']:checked').val() ? $('input[name=\'opt1\']:checked').val() : '') + '&opt2=' + encodeURIComponent($('input[name=\'opt2\']:checked').val() ? $('input[name=\'opt2\']:checked').val() : '') + '&comment=' + encodeURIComponent($('textarea=[name=\'comment\']').val()) + '&agree=' + encodeURIComponent($('input[name=\'agree\']:checked').val() ? $('input[name=\'agree\']:checked').val() : ''), beforeSend: function() { $('.success, .warning').remove(); $('#confirm_button').attr('disabled', 'disabled'); $('#confirm_title').after('<div class="wait"><img src="mage/loading_1.gif" alt="" /> <?php echo $text_wait; ?></div>'); }, complete: function() { $('#confirm_button').attr('disabled', ''); $('.wait').remove(); }, success: function(data) { if (data.error) { $('#confirm_title').after('<div class="warning">' + data.error + '</div>'); } if (data.success) { $('#confirm_title').after('<div class="success">' + data.success + '</div>'); $('input[name=\'opt1\']:checked').attr('checked', ''); $('input[name=\'opt2\']:checked').attr('checked', ''); $('input[name=\'agree\']:checked').attr('checked', ''); } } }); } The Problem is won't work with IE only, I tested it with IE 6, Anyone could suggest me what I could do? any pointers, samples or links I would be appreciate and Thanks a lot. I'm using jquery right now but I sort of understand what the problem is. I'm making a file manager and when you click on an li tag it will do some action depending on if it's a file type or a folder type. There are 3 important files you should know about. 1. filemanager.php (Where the file managing takes place. Starts by including filemanager_getfile.php and including filemanager.js in the head). 2. filemanager_getfile.php (Information that receives information from the ajax request [the directory to be read] and prints the new file list in <li> tags) 3. filemanager.js (Jquery that processes li clicks) The problem is, when you click on a folder (and it loads the new information from the ajax request) the jquery doesn't check the new li tags when clicked (I'm guessing when you first link the javascript file it has to compile all of the current li information?). Try it for yourself- [removed] Instruction (if it's not already obvious): -Clicking a file selects if. If files are selected and you click the arrow in the file options it will transfer it (not really, but it will later). -Clicking a folder will send an ajax request with the new directory information to be checked and return the html -Clicking the '?' in the file options will display the pages html (I implemented it to debug). I have tried linking the js page every time I include the new directory information, but the js stacks on each other. So if I click on 3 folders and hit the '?' button it will display the page html 3 times. And if I select the index.php li and click transfer, it will "transfer" 3 times. filemanager.php Code: <div id="goldenSub"> <div class="title">Golden Subdomain</div> <div class="files" id="goldenSubFiles"> <? include("filemanager_getfiles.php"); ?> </div> <div id="history" visited="goldensub/"></div>; <div class="fileOptions"><img src="images/question.png" title='HTML Information' id="ask"><img src="images/transferto.png" title='Copy File To' id="transferTo"></div> </div> filemanager_getfiles.php PHP Code: <? $path = $_REQUEST["dir"]; if($path == "" || $path == null) { $path = 'goldensub/'; } echo "\n<div class='path'>$path</div>\n<ul>\n"; $handler = opendir($path); //We need to organize the results. Be default, all files and folders will be //located by alphabetical order. But we want to list all folders first, followed //by files. By adding the results to arrays first we can decide to print our //results in the order we want. $folderArray = array(); $fileArray = array(); $folderCount = 0; $fileCount = 0; while(false !==($file=readdir($handler))) { if($file != "" && $file != null && $file != "." && $file != "..") { $extensionLocation = strrpos($file, "."); //Is this a folder or a file? if($extensionLocation == null && $extensionLocation == "") { //This is a folder unless it's the error_log file. if($file != "error_log") { //Nope, it's definitly a folder. Add it to the folder array. $folderCount++; $folderArray[$folderCount] = $file; } } else { //This is a file. Add it to the file array. $fileCount++; $fileArray[$fileCount] = $file; } } } if($path != 'goldensub/') { echo "\t<li title='goldensub/' type='folder'>\n\t\t<img src='images/up.png'> goldensub\n\t</li>\n"; } for($i = 1; $i<=$folderCount; $i++) { $newPath = $path.$folderArray[$i].'/'; echo "\t<li title='$newPath' type='folder'>\n\t\t<img src='images/folderOpen.png'> $folderArray[$i]\n\t</li>\n"; } for($i = 1; $i<=$fileCount; $i++) { $extensionLocation = strrpos($fileArray[$i], "."); $nameLength = strlen($fileArray[$i]); $extensionLength = $nameLength-$extensionLocation; $nameClean = substr($fileArray[$i], 0, $extensionLocation); $extension = substr($fileArray[$i], $extensionLocation+1, $nameLength); echo "\t<li title='$fileArray[$i]' type='file' extension='$extension'>\n\t\t\n\t<img src='images/$extension.png'> $nameClean\n\t</li>\n"; } echo "</ul>"; ?> filemanager.js Code: $("li").click(function(){ var type = $(this).attr("type"); //This is a folder if(type == "folder") { //Path to new directory var newPath = $(this).attr("title"); //Ajax request to filemanager_getfiles.php $("#goldenSubFiles").load("filemanager_getfiles.php", { dir: newPath }, function(data){ //Update log newLog("Directory changed to <i><b>"+newPath+"</b></i>"); }); } //This is a file else { if($(this).hasClass("selected")) { //It's already selected - deselect it. $(this).removeClass("selected"); } else { //Select it $(this).addClass("selected"); } } }); Hi, I have some basic code that allows me to press a button that inserts a new row in to my table, which also includes a text box. I also have a button that "should" allow me to remove the last text box. However, for some reason it doesn't work and I can't figure out why. The commented area works fine when active and accurately tells me the amount of rows that have been inserted. It is simply the delete part that doesn't work. Here is my code; PHP Code: var currentTxtBx = 0; function addRow(tableID) { if (currentTxtBx<10){ if (currentTxtBx<10){ var table = document.getElementById(tableID); var rowCount = table.rows.length; var row = table.insertRow(rowCount); var cell1 = row.insertCell(0); var element1 = document.createElement("input"); element1.type = "text"; element1.name = 'check'+(currentTxtBx+1); currentTxtBx++; cell1.appendChild(element1); } } else { alert('cannot add more than 10 boxes'); } } function deleteRow(tableID) { var allTxtBxs = document.getElementById('dataTable').getElementsByTagName('input'); if(allTxtBxs.length == 0){ alert('there are no text boxes to remove'); } else { //alert('you have ' +allTxtBxs.length+ ' textboxes'); document.getElementById('dataTable').removeChild(allTxtBxs[allTxtBxs.length-1]); currentTxtBx = allTxtBxs.length; } } If anyone could provide any advise or a solution to help me overcome this problem I would really appreciate it. Thanks. Code: function addEvent(elem,type,func) { var obj = document.getElementById(elem); if(window.addEventListener) { obj.addEventListener(type,func,false); } if(window.attachEvent) { obj.attachEvent('on'+type,func); } } function $e(obj) { if(obj) obj = document.getElementById(obj); if(!obj) return; return obj; } function homeFunc() { $e('home-wrapper').innerHTML = "<div id=\"choose-container\"><span class=\"choose-buttons\" onclick=\"loginFunc()\">Login Exisiting Account</span><span class=\"choose-buttons\" id=\"createAcct\">Create An New Account</span><span class=\"choose-buttons-highscores\" id=\"createAcct\">Highscores Table</span>"; } function loginFunc() { $e('home-wrapper').innerHTML = "<div id=\"login-container\"><div id=\"error-field\"></div><form method=\"post\" onsubmit=\"return validate_login()\" action=\"./index.php\"><label for=\"username\">Username</label><input name=\"username\" id=\"username\" class=\"input\" type=\"text\" /> <label for=\"password\">Password</label><input name=\"password\" id=\"password\" class=\"input\" type=\"password\" /><input name=\"login\" type=\"submit\" value=\"Login\" class=\"loginButtonClass\" /><div id=\"loginQuickLinks\"><span class=\"loginQuickLinks\" onclick=\"homeFunc()\">Register</span> - <span class=\"loginQuickLinks\">Forgot password?</span></form></div></div>"; } function createAcct() { alert("Create An Account"); } function validate_usr() { var usr = $e('username'); var pwd = $e('password'); if(usr.value.length <= 0 && pwd.value.length <= 0) { loginErrorMsg('Please supply a username and password.'); return false; } if(usr.value.length >= 1 && pwd.value.length <= 0) { loginErrorMsg('Please supply a password.'); return false; } if(pwd.value.length >= 5 && usr.value.length <= 0) { loginErrorMsg('Please supply a username.'); return false; } if(pwd.value.length < 5) { loginErrorMsg('Invalid username or password.'); return false; } if(usr.value.length >= 1 && pwd.value.length >= 5) { $e('error-field').style.cssText='display:block;'; $e('error-field').innerHTML = "<img src=\"/images/ajax-loader.gif\" /> <span style=\"color:#ffffff\">Loading...</span>"; var req; var params = 'user='+encodeURIComponent(usr.value.toLowerCase())+'&pass='+encodeURIComponent(pwd.value.toLowerCase()); if(window.XMLHttpRequest) { req = new XMLHttpRequest(); } if(window.ActiveXObject) { req = new ActiveXObject("Msxml2.XMLHTTP" || "Microsoft.XMLHTTP"); } req.open('POST','server/userChck.php',true); req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); req.send(params); req.onreadystatechange = req; if(req.readyState == 4 && req.status == 200) { if(req.responseText == 0) { window.scrollTo(0,1); setTimeout(function(){loginErrorMsg('Invalid username or password');},1000); return false; } } } return true; } function loginErrorMsg(msg) { window.scrollTo(0,1); $e('error-field').innerHTML = msg; $e('error-field').style.cssText='display:block'; } function validate_login() { var isTurn = (!validate_usr()) ? false : true; return isTurn; } window.onload = function() { setTimeout(function(){window.scrollTo(0,1);},100); addEvent('loginButton','click',loginFunc); addEvent('createAcct','click',homeFunc); } This code works fine when I set this line to false Code: req.open('POST','server/userChck.php',false); but as soon as I set this to true. I doesn't work.... What am I doing wrong here? Hi all, I am new with AJAX, and when trying to hack the core file of Open Cart I met a problem with one javascript block of code. Thise code deal with checkout process in Open Cart 1.5.1.3. I have read through all of them but don't understand much. So can you tell me how it work just before the REGISTER field (line 1-147). Thank so much! Hello: I have an ajax file to loads the content of another file into a div, here is the js code: PHP Code: <script type="text/javascript"> function showUser(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getcar.php?q="+str,true); xmlhttp.send(); } </script> the file within xmlhttp (getcar.php) has other js codes that are to be executed once the file is loaded into the div. here is one of those files: PHP Code: <!-- loading, please wait message script begins--> <div id="loading\" class=\"loading-invisible\" z-index: 999> <p><font color=\"black\" size='4'>one moment, please!</font> <font color=#218868> Auto Tech Pro « Initiating... » </font><br /><img border='0' src='images/spinnnnnn.gif' width='215px' height='206px'> </div> <script type=\"text/javascript\"> document.getElementById(\"loading\").className = \"loading-visible\"; var hideDiv = function(){document.getElementById(\"loading\").className = \"loading-invisible\";}; var oldLoad = window.onload; var newLoad = oldLoad ? function(){hideDiv.call(this);oldLoad.call(this);} : hideDiv; window.onload = newLoad; </script> <!-- loading, please wait message script ends--> <script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js\"></script> <script src=\"/AJAX/popBox1.2.0.js\" type=\"text/javascript\"></script> <link href=\"/AJAX/popBox1.2.0.css\" rel=\"stylesheet\" type=\"text/css\" /> <script type=\"text/javascript\"> $(document).ready(function () { $('#inputbox').popBox({width:550, newlineString: '<br/>' }); }); </script> this however is not working. If I open getcar.php independently of the ajax, the preceeding js codes work fine, but not once the ajax loads the file into div. Any thoughts on how this is doable? Mossa How come the below code is not woring for me? when someone comments on my facebook comments plugin I want to get an email. This is what i have Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <div id="fb-root"></div> <script> window.fbAsyncInit = function() { FB.init({ appId : '220041184732123', // App ID channelUrl : '//http://www.corkdiscos.com/channel.html', // Channel File status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML }); FB.subscribe('comment.create', function(response){ // Here you need to do a call to some service/script/application // to notify your administrator about new comment. // I'll use jQuery ajax to call server-side script to illustrate the flow $.post('mail.php', { "action": "comment created", "url_of_page_comment_leaved_on": response.href, "id_of_comment_object": response.commentID }); }); }; // Load the SDK Asynchronously (function(d){ var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; d.getElementsByTagName('head')[0].appendChild(js); }(document)); </script> <div class="fb-comments" notify="true" data-href="http://www.corkdiscos.com/testimonials.html" data-num-posts="30" data-width="544"></div> </body> </html> I then have this php code to send me a mail in a mail.php file PHP Code: <?php $admin_email = 'corkdjs@gmail.com'; $commentID = $_REQUEST['id_of_comment_object']; $page_href = $_REQUEST['url_of_page_comment_leaved_on']; $message = "hello"; mail($admin_email, You have a new comment", $message); ?> what could be wrong and is there anyone that knows how to fix this to make it work? For some reason it does not work. It should when a player value is = NaN than the players NaN value should be equal to the players value before he was NaN Code: <script type="text/javascript"> function start(){ var t=setTimeout("roll()",500); var t=setTimeout("p11()",1000); var t=setTimeout("roll()",3001); var t=setTimeout("p12()",4002); var t=setTimeout("roll()",5003); var t=setTimeout("p13()",6004); var t=setTimeout("roll()",7005); var t=setTimeout("p14()",8006); var t=setTimeout("roll()",9006); var t=setTimeout("start()",9007); } function roll(){ var a = randoma=Math.floor(Math.random()*7); var b = randomb=Math.floor(Math.random()*7); document.getElementById("r1").value = a; document.getElementById("r2").value = b; } </script> <script type="text/javascript"> function p11(){ if (document.getElementById("r1").value == document.getElementById("r2").value ) { document.getElementById("n1").value == document.getElementById("p1").value ; document.getElementById("p1").value = "NaN"; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; } if (document.getElementById("r1").value < document.getElementById("r2").value ) { document.getElementById("p1").value ++; document.getElementById("p1").value ++; document.getElementById("p1").value ++; document.getElementById("p1").value ++; document.getElementById("p1").value ++; document.getElementById("p1").value ++; document.getElementById("p1").value ++; document.getElementById("p1").value ++; document.getElementById("p1").value ++; document.getElementById("p1").value ++; } if (document.getElementById("r1").value > document.getElementById("r2").value ) { document.getElementById("p1").value ++; document.getElementById("p1").value ++; document.getElementById("p1").value ++; document.getElementById("p1").value ++; document.getElementById("p1").value ++; } } </script> <script type="text/javascript"> function p12(){ if (document.getElementById("r1").value == document.getElementById("r2").value ) { document.getElementById("n2").value == document.getElementById("p2").value ; document.getElementById("p2").value = "NaN"; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; } if (document.getElementById("r1").value < document.getElementById("r2").value ) { document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; } if (document.getElementById("r1").value > document.getElementById("r2").value ) { document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; } } </script> <script type="text/javascript"> function p13(){ if (document.getElementById("r1").value == document.getElementById("r2").value ) { document.getElementById("n3").value == document.getElementById("p3").value ; document.getElementById("p3").value = "NaN"; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p1").value ++; document.getElementById("p1").value ++; document.getElementById("p1").value ++; document.getElementById("p1").value ++; document.getElementById("p1").value ++; } if (document.getElementById("r1").value < document.getElementById("r2").value ) { document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; } if (document.getElementById("r1").value > document.getElementById("r2").value ) { document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; } } </script> <script type="text/javascript"> function p14(){ if (document.getElementById("r1").value == document.getElementById("r2").value ) { document.getElementById("n4").value == document.getElementById("p4").value ; document.getElementById("p4").value = "NaN"; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p2").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p3").value ++; document.getElementById("p1").value ++; document.getElementById("p1").value ++; document.getElementById("p1").value ++; document.getElementById("p1").value ++; document.getElementById("p1").value ++; } if (document.getElementById("r1").value < document.getElementById("r2").value ) { document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; } if (document.getElementById("r1").value > document.getElementById("r2").value ) { document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; document.getElementById("p4").value ++; } } </script> Code: Player 1 $<input type="text" value="0" id="p1" size="1" style="background-color:transparent;border:0px solid white;"Readonly /> <br/> Player 2 $<input type="text" value="0" id="p2" size="1" style="background-color:transparent;border:0px solid white;"Readonly /> <br/> Player 3 $<input type="text" value="0" id="p3" size="1" style="background-color:transparent;border:0px solid white;"Readonly /> <br/> Player 4 $<input type="text" value="0" id="p4" size="1" style="background-color:transparent;border:0px solid white;"Readonly /> <br/> <input type="button" value="Roll" onclick="start()"/> <br/> <input type="hidden" value="0" id="r1" size="1" /> <input type="hidden" value="0" id="r2" size="1" /> Player 1 NaN $<input type="text" value="0" id="n1" size="1" style="background-color:transparent;border:0px solid white;"Readonly /> <br/> Player 2 NaN $<input type="text" value="0" id="n2" size="1" style="background-color:transparent;border:0px solid white;"Readonly /> <br/> Player 3 NaN $<input type="text" value="0" id="n3" size="1" style="background-color:transparent;border:0px solid white;"Readonly /> <br/> Player 4 NaN $<input type="text" value="0" id="n4" size="1" style="background-color:transparent;border:0px solid white;"Readonly /> function paymentmeth() { for (i = 0; i < document.merch.payway.length; i++){ if (document.merch.payway[i].checked == true){ //a loop that is used to determine the paymethod and checks to see if data has been entered method = document.merch.payway[i].value } } if (method == false) { alert("You forgot to select Pay Method.") } } Hi everyone, Kind of new to this but I can't get my page to work in IE, works fine in all other browsers though. Any help would be greatly appreciated! the site is sthfilm.com and the code is below: Code: <html> <head> <title>Shortcut to Heaven</title> <link rel="stylesheet" href="style.css"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" charset="utf-8"> </script> <script type="text/javascript"> <!-- Activate cloaking device var randnum = Math.random(); var inum = 4; var rand1 = Math.round(randnum * (inum-1)) + 1; images = new Array images[1] = "img/bg.jpg" images[2] = "img/bg2.jpg" images[3] = "img/bg3.jpg" images[4] = "img/bg4.jpg" var image = images[rand1] // Deactivate cloaking device --> $(function(){ var menu = $('#menu'), pos = menu.offset(); $(window).scroll(function(){ if($(this).scrollTop() > pos.top+menu.height() && menu.hasClass('default')){ menu.fadeOut('fast', function(){ $(this).removeClass('default').addClass('fixed').fadeIn('fast'); }); } else if($(this).scrollTop() <= pos.top && menu.hasClass('fixed')){ menu.fadeOut('fast', function(){ $(this).removeClass('fixed').addClass('default').fadeIn('fast'); }); } }); }); $(function(){ var bar = $('#bar'), pos = bar.offset(); $(window).scroll(function(){ if($(this).scrollTop() > pos.top+bar.height() && bar.hasClass('default2')){ bar.fadeOut('fast', function(){ $(this).removeClass('default2').addClass('fixed2').fadeIn('fast'); }); } else if($(this).scrollTop() <= pos.top && bar.hasClass('fixed2')){ bar.fadeOut('fast', function(){ $(this).removeClass('fixed2').addClass('default2').fadeIn('fast'); }); } }); }); </script> </head> <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <script language="JavaScript"> <!-- Activate cloaking device document.write('<img src="' + image + '" class="bg">') // Deactivate cloaking device --> </script> <div id="navi"> <div id="bar" class="default2" align=center> <div id="menu" class="default" align=center> <!--code of floating bar goes here--> <h1>For additonal information on this project please contact ...</a></h1> </div> </div> </div> </body> </html> Hi, i got good help with this last time but i still wonder if its possible to make this work in ie explorer. The script is a expandable menu where the submenus still shall be shown if javascript is disabled for some reason, it works in firefox but i in ie it shows all links as submenus on load . i wonder if it would be possible to show the menus unexpanded on load in i explorer to . note that the submenus should only be visible on load if javascript is disabled. Im posting the code below i would aprreciate some help <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> .menu1{ margin-left:25px; padding-left:20px; padding-top:2px; padding-bottom: 2px; display:block; text-decoration: none; color: #000000; height: 20px; width: 200px; background-color: #03C; border: thin solid #FFF; } .submenu{ background-image: url(images/submenu.gif); display: block; height: 19px; margin-left: 38px; padding-top: 2px; padding-left: 7px; color: #333333; } .hide{ display: none; } .show{ display: block; } </style> </head> <body> <a class="menu1" onclick="showHide('mymenu1')">Menu 1</a> <div id="mymenu1" class="show"> <a href="#" class="submenu">Link One here</a> <a href="#" class="submenu">Link Two here</a> <a href="#" class="submenu">Link Three here</a> <a href="#" class="submenu">Link Four here</a> </div> <a class="menu1" onclick="showHide('mymenu2')">Menu 2 </a> <div id="mymenu2" class="show"> <a href="#" class="submenu">Link One here</a> <a href="#" class="submenu">Link Two here</a> <a href="#" class="submenu">Link Three here</a> <a href="#" class="submenu">Link Four here</a> </div> <a class="menu1" onclick="showHide('mymenu3')">Menu 3 </a> <div id="mymenu3" class="show"> <a href="#" class="submenu">Link One here</a> <a href="#" class="submenu">Link Two here</a> <a href="#" class="submenu">Link Three here</a> <a href="#" class="submenu">Link Four here</a> </div> <a class="menu1" onclick="showHide('mymenu4')">Menu 4 </a> <div id="mymenu4" class="show"> <a href="#" class="submenu">Link One here</a> <a href="#" class="submenu">Link Two here</a> <a href="#" class="submenu">Link Three here</a> <a href="#" class="submenu">Link Four here</a> </div> <a class="menu1" onclick="showHide('mymenu5')">Menu 5 </a> <div id="mymenu5" class="show"> <a href="#" class="submenu">Link One here</a> <a href="#" class="submenu">Link Two here</a> <a href="#" class="submenu">Link Three here</a> <a href="#" class="submenu">Link Four here</a> </div> <script type="text/javascript"> menu_status = new Array(); function showHide(theid){ var switch_id = document.getElementById(theid); if(menu_status[theid] != 'show') { switch_id.className = 'show'; menu_status[theid] = 'show'; } else { switch_id.className = 'hide'; menu_status[theid] = 'hide'; } } var divs=document.getElementsByTagName('div'); var menudivs=[]; for(i=0;i<divs.length;i++) { if(divs[i].id.indexOf('mymenu')!=-1) menudivs.push(divs[i]); } function hideDivs() { for(i=0;i<menudivs.length;i++) { menudivs[i].className='hide'; menu_status[menudivs[i]]='hide'; } } window.addEventListener('load',hideDivs,false); //window.attachEvent('onload',hideDivs) - add this within an "if IE" statement </script> </body> </html> So when I enter in numbers for the calculator the numerical grade shows, but not the letter grade. I dont know if I called the function wrong or if my if statement is wrong. I have no idea. Can someone help me please? Code: <!DOCTYPE html> <html lang="en"> <head> <title>Lab</title> <meta charset="utf-8"> <script> function calculateGrade () { var test1 = document.getElementById("t1") var test2 = document.getElementById("t2") var finalexam = document.getElementById("t3") var labs = document.getElementById("t4") var projects = document.getElementById("t5") var quizzes = document.getElementById("t6") var grade= document.getElementById("fng") grade.value=parseFloat(0.15*test1.value)+parseFloat(0.15*test2.value)+parseFloat(0.20*finalexam.value)+parseFloat(0.30*labs.value)+ parseFloat(0.05*projects.value)+parseFloat(0.15*quizzes.value) } function getLetterGrade() { if (totalGrade >= 90) letterGrade = "A"; else if (totalGrade < 90 && totalGrade >= 80) letterGrade = "B"; else if (totalGrade < 80 && totalGrade >= 70) letterGrade = "C"; else if (totalGrade < 70 && totalGrade >= 60) letterGrade = "D"; else if (totalGrade < 60 && totalGrade >= 50) letterGrade = "F"; } </script> </head> <body> <form id="form1" name="form1"> <table> <tr> <th colspan="2"> Score </th> </tr> <tr> <td> Test 1 </td> <td><input type="text" name="t1" id="t1" value= ""></td> </tr> <tr> <td> Test 2 </td> <td><input type="text" name="t2" id="t2" value= ""></td> </tr> <tr> <td> Final Exam </td> <td><input type="text" name="t3" id="t3" value=""></td> </tr> <tr> <td> Labs </td> <td><input type="text" name="t4" id="t4" value=""></td> </tr> <tr> <td> Projects </td> <td><input type="text" name="t5" id="t5" value=""></td> </tr> <tr> <td> Quizzes </td> <td><input type="text" name="t6" id="t6" value=""></td> </tr> <tr> <th colspan="2"> <input type="button" name="b1" id="b1" value="Calculate Grade" onclick="calculateGrade(); getLetterGrade()"> </th> </tr> <tr> <td> Final numerical grade </td> <td><input type="text" name="fng" id="fng" style="border: none"></td> </tr> <tr> <td> Final letter grade </td> <td><input type="text" name="letterGrade" id="letterGrade" style="border: none"></td> </tr> </table> </form> </body> </html> I have this javascript code in this html page and it works fine. As soon as I try to add it to an existing page, it doesn't work. I have tried every position for the form and the script that I can think of but to no avail. I would greatly appreciate soon expert guidance. Frank. The code page is here. The page that I am trying to add it to is here. Hi, I have a javascript I created to compare the textbox value to the array and write something on the textbox but somehow it is giving me a syntax error. I am not good in javascript so I am really not sure which one is giving me problem. Can someone please help? Thanks. My logic is to check if my 18 textbox is not empty and if not then get the label of each textbox and compare to my array listed below. If the value of each label in the textbox exist, then write and equal word in the hidden textbox and if it doesn't exist, increment to the value of 1 to the textbox. Here is my javascript code: Code: function CalculateTotal(){ var homelessness = new Array (); homelessness[0] = "70250", homelessness[1] = "70260", homelessness[2] = "70750", ); var financial = new Array (); financial[0] = "96580", financial[1] = "96500", financial[2] = "96580", ); var emergency = new Array (); emergency[0] = "79660", emergency[1] = "80105", emergency[2] = "96020", ); for (i=3; i<18; i++) for (var k=3; k<18; k++) { if((amounts[i] != "") && (amounts[i] == desig[k])) { var issueId = impact.charAt(k); var impact_txt = document.getElementById(issueId).value; for ( var x = 0; x < homelessness.length; x++ ) { var myArray[ homelessness[ x ] ] = homelessness[ x ]; if ( myArray[impact_txt] == homelessness[] ) && (document.getElementById('impact1').value == "")) { document.getElementById('impact1').value = "Homelessness"; } } for ( var x = 0; x < financial.length; x++ ) { var myArray[ financial[ x ] ] = financial[ x ]; if ( myArray[impact_txt] == financial[] ) && (document.getElementById('impact2').value == "")) { document.getElementById('impact2').value = "Financial Stability and Independence"; } } for ( var x = 0; x < emergency.length; x++ ) { var myArray[ emergency[ x ] ] = emergency[ x ]; if ( myArray[impact_txt] == emergency[] ) && (document.getElementById('impact2').value == "")) { document.getElementById('impact3').value = "Emergency Crisis and Services"; } } } } } } //body code <table> <tr> <td style="width:380px;text-align:left"><label for="d" id="D" name="D" title="80104">Crime and Drug Use <a href="javascript:alert('');">what is this?</a></label></td> <td style="float:right"> $<input id="d" name="d" class="text" type="text" value="<?php safeEcho($form['d'])?>" style="width:90px;" onChange="CalculateTotal();" /> <?php helper_error('d');?> </td><td> <input name="impact1" id="impact1" type="text" value="" onclick="CalculateTotal();" /> </td> </tr> <tr> <td style="width:380px;text-align:left"><label for="e" id="E" name="E" title="80101">Early Childhood Development <a href="javascript:alert('');">what is this?</a></label></td> <td style="float:right"> $<input id="e" name="e" class="text" type="text" value="<?php safeEcho($form['e'])?>" style="width:90px;" onChange="CalculateTotal()" /> <?php helper_error('e');?> </td><td> <input name="impact2" id="impact2" type="text" value="" onclick="CalculateTotal();" /> </td> </tr> <tr> <td style="width:380px;text-align:left"><label for="f" id="F" name="F" title="80105">Emergency and Crisis Services <a href="javascript:alert('');">what is this?</a></label></td> <td style="float:right"> $<input id="f" name="f" class="text" type="text" value="<?php safeEcho($form['f'])?>" style="width:90px;" onChange="CalculateTotal()" /> <?php helper_error('f');?> </td><td> <input name="impact3" id="impact3" type="text" value="" onclick="CalculateTotal();" /> </td> </tr> Hope you can help me to make my javascript work. Thanks. OK I am stumped. I am creating a little html to check my js file. I want to have the user enter two parameters and then call the function using those two paramaters and then display the answer on the screen. Here is the html file <!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>HomeWork3</title> <script type="text/JavaScript" src="grosspay.js"> </script> </head> <body> <script type="text/javascript"> <![CDATA[ var hoursWorked = parseInt(prompt("Enter the Number of Hours You Worked", "40")); var hourlyRate = parseInt(prompt("Enter the Number of Hours You Worked", "10")); function grossPay(hoursWorked, hourlyRate){ document.writeln(grossPay + " Is your normal amount of your check before taxes are taken out"); } ]]> </script> </body> </html> Here is the JS file function grossPay (hoursWorked, hourlyRate) { if (hoursWorked > 40){ var overTimeHrs = (hoursWorked - 40) var overTimePay = (overTimeHrs * 1.5 * hourlyRate) var regPay = (40 * hourlyRate) var grossPay = regPay + overTimePay return grossPay }else { var grossPay = (40 * hourlyRate) return grossPay} } CAN SOMEONE PLEASE HELP Hello, I have a script that lets you add tasks to a task list and then you can click a button to sort them, but I cannot get the "Delete Selected Task" and "Delete All Tasks" buttons to work correctly. I will be eternally indebted to whoever can help me fix these two buttons. The code I am working on is posted below. Thank you for your time. [CODE] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>To Do List</title> <script type="text/javascript"> /* <![CDATA[ */ function addTask() { if (document.forms[0].newtask.value == "") window.alert("You must enter a value in the New Task field."); else { if (document.forms[0].tasks.options.value == "tasks") document.forms[0].tasks.options[0] = null; var newTask = new Option(); newTask.value = document.forms[0].newtask.value; newTask.text = document.forms[0].newtask.value; var numTasks = document.forms[0].tasks.options.length; document.forms[0].tasks.options[numTasks] = newTask; document.forms[0].newtask.value = ""; } } function deleteTask() { var selectedTask = 0; var taskSelected = false; while (selectedTask < document.forms[0].tasks.length) { if (document.forms[0].tasks.options[selectedTask].selected == true) { taskSelected = true; break; } ++selectedTask; } if (taskSelected == true) document.forms[0].tasks.options[selectedTasks] = null; else window.alert("You must select a task in the list."); } function ascendingSort() { var newTasks = new Array(); for (var i =0; i < document.forms[0].tasks.length; ++i) { newTasks[i] = document.forms[0].tasks.options[i].value; } newTasks.sort(); for (var j =0; j < document.forms[0].tasks.length; ++j) { document.forms[0].tasks.options[j].value = newTasks[j]; document.forms[0].tasks.options[j].text = newTasks[j]; } } /* ]]> */ </script> </head> <body> <h1>To Do List</h1> <form action=""> <p>New Task <input type="text" size="68" name="newtask" /></p> <p><input type="button" value="Add Task" onclick="addTask()" style="width: 150px" /> <input type="button" value="Delete Selected Task" onclick="deleteTask()" style="width: 150px" /> <input type="button" value="Delete All Tasks" onclick="document.forms[0].task.options.length = 0;" style="width: 150px" /><br /> <input type="button" value="Ascending Sort" onclick="ascendingSort()" style="width: 150px" /> </p> <p><select name="tasks" size="10" style="width: 500px"> <option value="tasks">Tasks</option></select></p> </form> </body> </html> [CODE] Hi,my current pop under code works ever 24hrs,but I would like to change it to work every hour,and/or to work every time a member clears his cookies.If I am not explaining this correctly please let me know and I will try to correct this. Code: function setCookie(name, value, time) { var expires = new Date(); expires.setTime( expires.getTime() + time ); document.cookie = name + '=' + value + '; expires=' + expires.toGMTString(); } Any help with this would be greatly appreciated!! Mike Edit:If you need me to post the whole code I have no prob with this.I only posted this part because I thought the issue would be in var expires = new Date();. Just want to know what should I change it to? Here is the whole code. Code: <script type="text/javascript"> var puShown = false; function doOpen(url) { if ( puShown == true ) { return true; } win = window.open(url, 'wmPu', 'toolbar,status,resizable,scrollbars,menubar,location,height=700,width=1100'); if ( win ) { win.blur(); puShown = true; } return win; } function setCookie(name, value, time) { var expires = new Date(); expires.setTime( expires.getTime() + time ); document.cookie = name + '=' + value + '; expires=' + expires.toGMTString(); } function getCookie(name) { var cookies = document.cookie.toString().split('; '); var cookie, c_name, c_value; for (var n=0; n<cookies.length; n++) { cookie = cookies[n].split('='); c_name = cookie[0]; c_value = cookie[1]; if ( c_name == name ) { return c_value; } } return null; } function initPu() { if ( document.attachEvent ) { document.attachEvent( 'onclick', checkTarget ); } else if ( document.addEventListener ) { document.addEventListener( 'click', checkTarget, false ); } } function checkTarget(e) { if ( !getCookie('popundr') ) { var e = e || window.event; var win = doOpen('My Site Name Here/'); setCookie('popundr', 1, 24*60*60*1000); } } initPu(); </script> I do know that most of you hate pop ups and pop unders,but this is not to annoy my users.I am just using this to promote another site that I own..Thanks again. Code: var f = []; for ( var f1 = 1; f1 <= n; ++f1 ) { var f2 = n / f1; if ( f2 == Math.floor(f2) ) { f.push(f1); f.push(f2); } if ( f2 <= f1 ) break; } f.sort(); Someone helped me make this factoring code, but if n = 6, it returns [1,2,2,3,3,6,6,6] Any ideas? I am looking for [1,2,3,6] HTML: Code: <!-- video player begin --> <div id="playerHolder"> <div class="player" id="playerDiv"> <div id="playerwidget"></div> <div id="adCompanionBanner" style="visibility:hidden;"></div> </div> </div> In firefox, I type Code: javascript:document.getElementById("player").sendEvent(''SEEK", 0); into the Address bar and hit enter. Why doesn't it work? How do I correctly "seek" a video. |