JavaScript - If Statement - Not Responding To False Condition
Hi,
In the attached code the outcome always defaults to the first test, even if the condition is false. How would I alter the syntax so that both condtions are evalauted? Code: var res = document.calc.num1.value*100/document.calc.num2.value; function cost1() { if (isNaN(res)) { document.calc.result1.value=0; } else { document.calc.result1.value=document.calc.num1.value*100/document.calc.num2.value; } } Thanks Iain Similar Tutorialshello, only just starting using javascript, so question may not make sense but il try anyway. if i group some javascript into a function that returns false; how could i carry that 'false' out of the function so it can be used outside the function. the example below shows the validate function checks for a condition then returns false if it is met. i want this false to then be passed out of the function to then throw an error in its containing function. (goal to prevent the submitting of a form) if (checBox =="1"){ validate(); } function proceed(); function validate() { if (chilD1.value >70) { alert("Please enter your Childs correct Age"); return false; chilD1.focus(); } } i dont want the proceed function to be called, so how can the other function prevent this. Now i realise that the validate function could be incorporated into the top level function but, my form will eventually be quite large with a multiplitude of fields so i need to know how i can call back to functions and use them as objects insteasd of repeating lots of code. Hope you can help thanks. Hey all, I have a simple example below showing how when I pass in the value of the value attribute of option node, and then use if operator to check whether parameter is a string or not, even though it's a string, it converts it to false boolean and triggers the else statement rather than calling a function: Code: <body> <select> <option value="createMsg">Add Message</option> <option value="removeMsg">Remove Message</option> </select> </body> Code: var menu = { handleMenu : function(callback){ if(callback === "string"){ menu[callback](); } else { console.log("Issue occurred") } }, createMsg : function(){ var content = document.createTextNode("Please give additional information."), heading = document.createElement("h1"); heading.appendChild(content); document.body.appendChild(heading); }, removeMsg : function(){ } } document.getElementsByTagName('select')[0].onchange = function(){ menu.handleMenu(this.value)}; callback should be a string so why is it saying otherwise? Thanks for response I am building a shopping cart in Volusion. I've come really far and can find my way around HTML and CSS. But the template I am using has a zebra function that it uses on the shopping cart screen. The colors it is using are terrible, and I can't figure out how to change them. By zebra, I mean it picks every other row in a table and assigns a different background color. I am noticing in firebug that the div-ids of the items in the cart have div-ids taht are not listed in any of the CSS files in the theme. I figured out that this type of coding is usually done in JavaScripting. I tried editing that file in every logical way, and I can get no response out of it aside from my browser hanging. I even tried commenting out different sections. Also, the div-ids coming up in firebug aren't found in the .js file either. I'm not sure if you are at all familiar with Volusion, but they provide absolutely no assistance and try very hard to make things as hard as possible so customers will be desperate for their design services. All support will say is, "we are prohibited from providing any coding information. Would you like me to transfer you to sales?" They routinely remove resources that were once helpful. Nice customer service. Anyway, I've been working at this for days and I've come so far I hate being stuck at this point even though I'm just about ready to dump V. Can anyone give me any ideas on what to try? I feel like I've tried everything. I attached the file and here is the URL to the test site: http://v806427.kp5zkqan3xyu.demo22.volusion.com/ Thanks in advance, I'm dying over here. 1) I have a webpage that contains an iframe. The iframe is scrollable. 2) I have the main body of the page responding to onmouseup clicks: <body onmouseup="hideMenus(event)"> And I have the main body of the child page (displayed in the iframe) also responding to onmouseup clicks: <body onmouseup="parent.hideMenus(event)"> So clicks on both pages result in hideMenu() on the parent page being called. Now when the scroll bars on the iframe become visible (due to large amounts of content), I click on the scroll bar, and the hideMenus() function does not respond. I guess the scroll bar is not recognized as part of either the parent page or the iframe's page. I tried adding onmouseup="hideMenus(event)" to the iframe but that didn't help. How can I get mouse clicks on the iframe's scroll bar to result in hideMenu being called? The website can be viewed he http://www.shahspace.com/bow/home.html i have been searching the net to find a way to condition ondragover results by file type being dragged. Code: function doDragOver(event) { if(event.dataTransfer.types.contains('image/png')){ event.preventDefault(); } if(event.dataTransfer.types.contains('image/gif')){ event.preventDefault(); } if(event.dataTransfer.types.contains('image/jpg')){ event.preventDefault(); } if(event.dataTransfer.types.contains('image/jpeg')){ event.preventDefault(); } } this is waht i have been trying based on the ondragover documentation on the MDN network. i need preventDefault to be triggered if what i am dragging is an image from thee users hard drive and not triggered if the element is dragged from the browser. i can find no listing of type formats or even discovering file types for the dragged item on any network. I would greatly appreciate any help. ps. i have been stuck on this for three days now, i may be losing my mind I have an table in which an select box like this OS:<td > <select name="os" id="os" class="SelectList Width200"> </select> </td> following have an option in OS: windows/Linux i only want when user select OS - linux ... then function call otherwise if user select OS - window ... no need to call this function validate() i think it requires if condition in function Validate() .... can u ans me how it is posible to put if condition in function validate() function Validate() { var dropdownIndex = document.getElementById('type').selectedIndex; var sztype = document.getElementById('type')[dropdownIndex].value; if(sztype == "1") { var szpassword = ""; var szguid = ""; var name = Trim(document.userform.name.value); var ip = Trim(document.userform.ip.value); if(ip.length == 0) { alert("Please specify IP/Host Name."); return false; } if(name.length == 0) { name=ip; } szusername = Trim(document.userform.username.value); if(szusername.length == 0) { alert("Please specify Username."); return false; } var szvalidchars = new RegExp("[~!@#$%^&*()+|{}:\"<>?,/;'=\\`]"); if(szvalidchars.test(szusername)) { alert("Username cannot contain invalid characters."); return false; } szpassword = Trim(document.userform.password.value); if(szpassword.length == 0) { alert("Please specify Password."); return false; } The "?" seems to be called the conditional operator. Code: var points = prompt('How many points do you want on ten?'); var result = (points >= 5) ? "succeeded!" : "didn't succeed ;-)"; window.alert("You " + result); Hello all. I have started working on my companies website, http://www.janwyck.net Within it is an order form for ordering paint sundries from a shopping cart using javascript and cookies. After the customer selects a few items and fills out the form if they hit Submit, it brings up a pop-up that says First False. The only way I know to show you guys is to show the page code, I am sorry: Code: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="GENERATOR" content="Microsoft FrontPage 2.0"> <title>Janwyck Decorating Center</title> </head> <script language="javascript"> index = 0; function format(val, post) { var decpoint; var begin; var end; var valstr; var temp_char; valstr = "" + val; //alert('valstr = ' + valstr); decpoint = valstr.indexOf(".") if (decpoint != -1) { //alert('decpoint = ' + decpoint); begin = valstr.substring(0,decpoint); end = valstr.substring(decpoint+1,valstr.length); //alert('begin = ' + begin + '\nend= ' + end); } else { begin = valstr; end = ""; } if (end.length < post) {while (end.length < post) { end += "0"; } } end = end.substring(0,post); //alert('begin = ' + begin + '\nend= ' + end); return (begin+"."+end); } function orderSubmit(type) { if (type == 'order') {if ( ! ( (document.order.order_type.checked) || checkRequired() )) { // checkCardNumber(); ENTRY HERE alert('first true'); document.order.form_action.value = type; document.order.submit(); return true; } else { alert('first false'); return false; } } } var infowin = null; function copyToShipping() { if (document.order.same_flag.checked) { document.order.ship_name.value = document.order.name_first.value+' '+document.order.name_last.value; document.order.ship_address1.value = document.order.address1.value; document.order.ship_address2.value = document.order.address2.value; document.order.ship_city.value = document.order.city.value; document.order.ship_state.value = document.order.state.value; document.order.ship_zip.value = document.order.zip.value; document.order.ship_country.value = document.order.country.value; document.order.ship_phone.value = document.order.phone.value; } } function disableSameFlag() { document.order.same_flag.checked = false; } function checkRequired() { if (!document.order.name_first.value.length || !document.order.name_last.value.length || !document.order.email.value.length || !document.order.address1.value.length || !document.order.city.value.length || !document.order.state.value.length || !document.order.zip.value.length || !document.order.country.value.length) { alert('You have not completed all required fields:\n' + 'Please complete the Name, Address, City,\n' + 'County, Post Code, and Country in the\n' + 'Customer Info section'); return true; } else { return false; } } <!-- --> </script><!-- --><a name="top"></a> <body background="images/thisback.gif" bgcolor="#FFFFFF" text="#000000" onLoad=parent.refresh_ship_details(parent.ship_details) onUnload=parent.add_ship_details(parent.ship_details)> <center> <script language="javascript"> <!-- hide if (self==parent){document.write('<font color=#ff000><b>This is a frame element, click <a href=index.htm> here </a>for correct page</b></font>')}; <!-- end hide --> </script> <p><font color="#FF0000" size="7"><i>Janwyck Order Form</i><br> </font></p> <table border="0" width=400> <tr> <td align="center" bgcolor="#FF0000"><font color="#FFFFFF"><b>Please wait while the scripted order form is generated....... </b></font> </td> </tr> </table> <p><font size="6">Order Form</font> <br> <!-- HEY!!! PUT YOUR EMAIL ADDRESS IN THE LINK BELOW SO THEY CAN WRITE TO YOU --> <b>In the event of difficulty with this script please email us direct on <a href=mailto:janwyckpaint@gmail.com>Janwyck Paint</a> or call us on (706)865-2811</b> </p> <!-- YOU CAN PUT YOUR EMAIL ADDRESS IN THE FORM COMMAND BELOW AND THE --> <!-- THEN IT WILL BE SENT TO YOU AS A SIMPLE MAILTO GUESTBOOK FORM --> <!-- IF YOU DO THAT - BE SURE TO ADD THE COMMAND enctype="plain/text" --> <!-- IN ORDER TO DELINEATE THE MAIL FOR YOU --> <!-- YOU CAN ALSO USE TE .PL FILE AS A CGI TO HELP WTH THE MAIL. SEE THE TUTORIAL --> <!-- FOR MORE ON HOW THAT IS DONE --> <form action="MAILTO:janwyckpaint@gmail.com" method="POST" name="order" enctype="plain/text"> <input type="hidden" name="Order Form" value="Order Forms - Order Form"><input type="hidden" name="recipient" value="janwyckpaint@gmail.com"><input type="hidden" name="redirect" value="thanku.htm"><input type="hidden" name="retailer" value="Janwyck Decorating Center"><input type="hidden" name="form_action" value="order"> <script language="javascript"> <!-- hide from Browsers document.write('<table width=400><td align=center>'); document.write('<table width=400 ><tr><tr><td align=right colspan=3 BGCOLOR=#FF9999><font size=+2>Running Total : $ </td><td colspan=3 BGCOLOR=FF9999> <input type=text name=total size=6 value='+ format(parent.all_order_totals(),2) + '></font></td><tr>'); document.write('<td colspan=6 align=center><b>This is your Order Total so far<br>.</td></tr><tr></table>'); if (parent.items_ordered == 0) document.write('<font color=#000080><b>You have not ordered any items so far<b></font>'); if (parent.item_num > 0) { for (i =1;i < parent.item_num;i++) { if (parent.itemlist[i].quan > 0) {index = index + 1; document.write('<a href='+ parent.itemlist[i].url + '><i><b> review : </b></i></a><input size=10 type=text name= ' + parent.itemlist[i].code + ' value= ' + parent.itemlist[i].code + '><input size=6 type=text name= ' + parent.itemlist[i].code + ' value=' + parent.itemlist[i].price + '><input size=20 type=text name= ' + parent.itemlist[i].code + ' value= '+ parent.itemlist[i].desc + '><input size=2 type=text name= ' + parent.itemlist[i].desc + ' value= '+ parent.itemlist[i].quan + '><br>'); } } } <!-- end hiding --> </script> <table border="0" width=400> <tr> <td align="center" colspan="6" bgcolor="#FF9999"><b>Comments & Additional Information <br><font color=#ffff00>Can be written in the box below</font><br> </b></td> </tr> <tr> <td colspan="6"><center><textarea name="comments" rows="10" cols="40"></textarea></center></td> </tr> </table> <!-- Customer Info Table --> <table border="0" cellpadding="0" cellspacing="0" bgcolor="#00FFFF" width=400> <tr> <td align="center" colspan="5" bgcolor="#CCFFFF"><b>Customer Information / Details</b></td> </tr> <tr> <td align="right" colspan="2" bgcolor="#CCFFFF"><b>First Name: </b></td> <td colspan="3" bgcolor="#CCFFFF"><input type="text" size="30" maxlength="30" name="name_first"></td> </tr> <tr> <td align="right" colspan="2" bgcolor="#CCFFFF"><b>Last Name:</b> </td> <td colspan="3" bgcolor="#CCFFFF"><input type="text" size="30" maxlength="30" name="name_last"></td> </tr> <tr> <td align="right" colspan="2" bgcolor="#CCFFFF"><b>Email Address:</b> </td> <td colspan="3" bgcolor="#CCFFFF"><input type="text" size="30" maxlength="60" name="email"></td> </tr> <tr> <td align="right" colspan="2" bgcolor="#CCFFFF"><b>Address:</b> </td> <td colspan="3" bgcolor="#CCFFFF"><input type="text" size="30" maxlength="60" name="address1"></td> </tr> <tr> <td align="right" colspan="2" bgcolor="#CCFFFF"> </td> <td colspan="3" bgcolor="#CCFFFF"><input type="text" size="30" maxlength="60" name="address2"></td> </tr> <tr> <td align="right" colspan="2" bgcolor="#CCFFFF"><b>City:</b> </td> <td colspan="3" bgcolor="#CCFFFF"><input type="text" size="30" maxlength="30" name="city"></td> </tr> <tr> <td align="right" colspan="2" bgcolor="#CCFFFF"><b>County:</b> </td> <td bgcolor="#CCFFFF"><input type="text" size="8" maxlength="10" name="state"></td> <td align="right" bgcolor="#CCFFFF"><b>Post Code:</b> </td> <td bgcolor="#CCFFFF"><input type="text" size="9" maxlength="10" name="zip"></td> </tr> <tr> <td align="right" colspan="2" bgcolor="#CCFFFF"><b>Country:</b> </td> <td colspan="3" bgcolor="#CCFFFF"><input type="text" size="25" maxlength="25" name="country" value="UK"></td> </tr> <tr> <td align="right" colspan="2" bgcolor="#CCFFFF"><b>Phone:</b> </td> <td colspan="3" bgcolor="#CCFFFF"><input type="text" size="25" maxlength="25" name="phone"></td> </tr> <tr> <td align="right" colspan="2" bgcolor="#CCFFFF"><b>Fax:</b> </td> <td colspan="3" bgcolor="#CCFFFF"><input type="text" size="25" maxlength="25" name="fax"></td> </tr> <tr> <td align="center" colspan="5" bgcolor="#CCFFFF"><input type="checkbox" name="mail_list">Check here to be included on our mailing list </td> </tr> </table> <p align="center"><br> <p align="center"><br> <!-- Order Method Table --> </p> <table border="0" cellspacing="0" width=400> <tr> <td align="center" colspan="5" bgcolor="#CCFFFF"><font size="4"><b>Choose Order Method:</b></font></td> </tr> <tr> <td align="center" colspan="5" bgcolor="#CCFFFF"> <font size="2">Phone Call: <input type="radio" name="order_type" value="phone"></font> </td> </tr> <tr> <td align="center" colspan="5" bgcolor="#CCFFFF"><a href="options.htm" target=navigate> </td> </tr> </table> <p><br> <p><br> <p align="center"><br> <input type="button" value="Place Order" onclick="orderSubmit('order')"> <input type="reset" value="Reset Address Details"> </p> </form> </td></table> </center> </p> </body > </html> I hate posting that much code. I think though that it might be related to: Code: function orderSubmit(type) { if (type == 'order') {if ( ! ( (document.order.order_type.checked) || checkRequired() )) { // checkCardNumber(); ENTRY HERE alert('first true'); document.order.form_action.value = type; document.order.submit(); return true; } else { alert('first false'); return false; } } } But I am not quiet sure. ANy help I may get is greatly appreciated as the site is very close to going live and this is my BIG problem. Hi to All, I have two menus, related each other, in this way: <head> var sum_db = new Object() sum_db["email1"] = [{value:"I01 - Problems of one level", text:"I01 - Problems of one level"}, {value:"I02 - Problems RDM", text:"I02 - Problems RDM"}, {value:"Free Text", text:"Free Text "}]; sum_db["email2"] = [{value:"I03 - Various", text:"I03 - Various"}]; // // function setIssue(chooser) { var newElem; var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null; var Iss_Chooser = chooser.form.elements["iss_sum"]; while (Iss_Chooser.options.length) { Iss_Chooser.remove(0); } var choice = chooser.options[chooser.selectedIndex].value; var db = sum_db[choice]; if (choice == "email1") { newElem = document.createElement("option"); newElem.text = "Choose an issue ..."; newElem.value = "Choose Issue ..."; Iss_Chooser.add(newElem, where); } for (var i = 0; i < db.length; i++) { newElem = document.createElement("option"); newElem.text = db[i].text; newElem.value = db[i].value; Iss_Chooser.add(newElem, where); if ((choice == "email1") && (db[i].text.indexOf('Free Text')==0)) { document.getElementById("label_des").style.display=""; } else { document.getElementById("label_des").style.display="none"; } } } // </script> </head> <body> <form> <select size="1" name="mess" id="mess" onchange="setIssue(this)"> <option value="email1" selected>email1</option> <option value="email2">email2</option> </select> .... .... <select id="iss_sum" name="iss_sum"> <option value="<%=objRS("Issue_Summary")%>" selected><%=objRS("Issue_Summary")%></option> </select> <label for="iss_des" id="label_des" style="display:none; vertical-align:top">Description:<textarea id="iss_des" name="iss_des"><%=objRS("Issue_Description")%></textarea> </label> My problem is: I would like that if I select ONLY email1 and ONLY the option "Free Text", appears the textarea with label Description. Up to know if one selects email1, automatically the textarea appears near for every option; it seems that the condition of the if is not respected !!! Thanks a lot in advance !!! Could anyone tell me (or link me to some place that can) why the following if-statement will execute? if (5!=6 || 7!=8) { alert("Why does this work?"); } Thanks Upon clicking a button, my script will send a request to a PHP file, which will create a database entry and return it to the script, using json. Involving what's returned (which is an integer), javascript will create new div elements with that integer in the element blocks. My fear is that when the user sends two (or more) requests and there's a difference in ping, or he just has packet loss - that request #2 will come back while request #1 is executing. I could add a forced delay, where the PHP script will not allow a second entry within 5 seconds of the last entry. However, I'm afraid that massive packetloss could still interfere. For example, this could result in 2 div elements having the number of the first request, and 1 element having the number of the second request. If possible, I would like to avoid forcing the user to refresh the page to make the SQL entry (i.e., create the element with javascript and without SQL/PHP, but then upon submission, reload the page and send them to SQL.) Any suggestions? Does anyone know why I am not getting an alert on an empty form INPUT value? Code: if (document.forms["form"]["targetname"].value == "" && document.forms["form"]["unknownname"] == false) { alert ("What ever"); return false; } document.forms["form"]["targetname"] is a form INPUT text document.forms["form"]["unknownname"] is a form INPUT checkbox I suspect the problem is due to 'false'.. but I can't figure out why. I am trying to do a pattern match and check something in a condition but cant get it to work. The first value changes and I need to check and do something if I get a hit on it. Code: var mydata = "?first=one&second=two&third=three"; if (mydata.indexOf("first") == "something") { alert("No Hit"); } else { alert("Hit"); } Basically I am trying to find out if first is equal to one in the mydata string. Please advise because my above attempt is not working. I can't figure this. Basically I have a dialogue pop out box. When you type a value in the pop out box,and press enter, it will change the value in the input boxes. Let say I have five input boxes, four of the input box has 7 as value,the last input box has 15 value. When I type 8 and enter, it should change only the value of 15(from 15 to 8) as 15 is greater than 8. If I type 4, it should change all the values of input boxes as all of the input box values are greater than 4. I have set the condition to 18 as input boxes are 18 columns. jsNewDisc is the user input value. Below are some pieces of codes. Of course if I type 5 and enter, this condition will change all the values in the five input boxes as they are all of greater value. If I input 8, input box that has a value of 15 will be the only one that will be change as it has greater value. Code: for (a=1;a < 18; a++){ if(document.getElementById('R4'+ a).value>jsNewDisc){ document.getElementById('R4'+ a).value = jsNewDisc; } } Hi, I have 3 sum fields which I want to change to a red colour if the value is > or < 100. Apparently this is a DAP, but I am using javascript to tweek some of the settings in DAP. function subtotal() if(document.getElementById("Sum1").value>100&&<100) { this.style.cssText='Z-INDEX: 2; LEFT: 6.667in; WIDTH: 0.729in; COLOR: red' { else this.style.cssText='Z-INDEX: 2; LEFT: 6.667in; WIDTH: 0.729in; COLOR: #339966' </SCRIPT> <SPAN class=MSTheme-Label id="Sum1_Label" style="Z-INDEX: 1; LEFT: 0.25in; OVERFLOW: hidden; WIDTH: 0.711in; POSITION: absolute; TOP: 0.125in; HEIGHT: 0.161in">Totals:</SPAN><SPAN class=MsoBoundSpan id="Sum1" onmouseover="subtotal()" dataFormatAs=TEXT style="Z-INDEX: 2; LEFT: 5.416in; WIDTH: 0.729in; COLOR: #339966; POSITION: absolute; TOP: 0.125in; HEIGHT: 0.187in" MsoTextAlign="General">Sum of Product 1</SPAN><SPAN class=MsoBoundSpan id="Sum2" onmouseover="subtotal()" dataFormatAs=TEXT style="Z-INDEX: 2; LEFT: 6.667in; WIDTH: 0.729in; COLOR: #339966; POSITION: absolute; TOP: 0.125in; HEIGHT: 0.187in" MsoTextAlign="General">Sum of Product 2</SPAN><SPAN class=MsoBoundSpan id="Sum3" dataFormatAs=TEXT style="Z-INDEX: 2; LEFT: 7.917in; WIDTH: 0.729in; COLOR: #339966; POSITION: absolute; TOP: 0.125in; HEIGHT: 0.187in" MsoTextAlign="General">Sum of Product 3</SPAN></DIV> I'm a noobie at coding, and I was wondeirng if anyone can help me with the coding. Many Thanks Currently I have a race condition existing in my Java script code. What I am trying to do with this code is convert all check boxes which are a part of the 'checkbox' class and are not checked into text boxes with a value of zero. Currently when you post a check box that is not checked it does not appear in the $_POST data. However I need to know all the values whether true or false for these particular set of check boxes. The code I have is he Code: function checkboxConvert() { var chkBxs = $$('.checkbox'); for (var i = 0; i < chkBxs.length; i++) { if (chkBxs[i].checked == false) { chkBxs[i].type = 'textbox'; chkBxs[i].value = '0'; } } setTimeout("document.productForm.submit();",1000); } Now the problem that I have been getting is that when I try to submit this form the values of the recently changed text boxes does not appear in the $_POST data. Therefore, as you can see above I have postponed the page submit for 1 sec and then I have all the data available to me. However as time goes on and my data set gets larger, 1 sec may no longer be enough. This I think is a race condition and I need to figure some way of running the code only after all the check boxes have been converted and they have their new values. I would have thought that this would be unnecessary from the start, but for some reason it's trying to run both pieces simultaneously and I can't submit until I have the proper values in place. Any help is much appreciated! I have the following form: Quote: <form action="/cgi-bin/script.cgi" method="POST" onsubmit="check_create()"> <fieldset> <legend>Create project</legend> Type <input id="type" type="text" name="type" size="20" /><br/> Name <input id="project" type="text" name="project" size="20" /><br/> Language to use <input id="language" type="text" name="language" size="20"/><br/> <input type="hidden" name="profile" value="[% profile %]"/> <input type="submit" value="Create" /> </fieldset> </form><br/> and check_create function is: Quote: function check_create() { var type = document.getElementById('type').value; var pname = document.getElementById('project').value; var language = document.getElementById('language').value; if ((type == '') || (pname == '') || (language == '')) { alert('You must complete form'); return false; } else alert('Ok'); } The problem is that return false doesn't work, but form lanch /cgi-bin/script.cgi. Where is the problem? Why return false doesn' work? Regards, savio please help i am working on a widget for samsung solstice phone . it is a animated clock. got code from another widget but i can not figure out how to make it show 12 hour time instead if 24 it looks like it contains the code just note sure how to make it work Here is the code below. Any help would be great. /* * jDigiClock plugin 2.1 * var Digital; var hours; var minutes; var month; var date; var day; var year; var currDate; var timeUpdate; var ampm = false; var vvv = 0; var MonthsOfYear = new Array(12); MonthsOfYear[0] = "01"; MonthsOfYear[1] = "02"; MonthsOfYear[2] = "03"; MonthsOfYear[3] = "04"; MonthsOfYear[4] = "05"; MonthsOfYear[5] = "06"; MonthsOfYear[6] = "07"; MonthsOfYear[7] = "08"; MonthsOfYear[8] = "09"; MonthsOfYear[9] = "10"; MonthsOfYear[10] = "11"; MonthsOfYear[11] = "12"; var DaysOfWeek = new Array(7); var DaysOfWeekS = new Array(7); var MonthNames = new Array(12); switch(GetLanguage()){ case "en": DaysOfWeek[0] = "Sunday"; DaysOfWeek[1] = "Monday"; DaysOfWeek[2] = "Tuesday"; DaysOfWeek[3] = "Wednesday"; DaysOfWeek[4] = "Thursday"; DaysOfWeek[5] = "Friday"; DaysOfWeek[6] = "Saturday"; DaysOfWeekS[0] = "Sun"; DaysOfWeekS[1] = "Mon"; DaysOfWeekS[2] = "Tue"; DaysOfWeekS[3] = "Wed"; DaysOfWeekS[4] = "Thu"; DaysOfWeekS[5] = "Fri"; DaysOfWeekS[6] = "Sat"; MonthNames[0] = 'Jan'; MonthNames[1] = 'Feb'; MonthNames[2] = 'Mar'; MonthNames[3] = 'Apr'; MonthNames[4] = 'May'; MonthNames[5] = 'Jun'; MonthNames[6] = 'Jul'; MonthNames[7] = 'Aug'; MonthNames[8] = 'Sep'; MonthNames[9] = 'Oct'; MonthNames[10] = 'Nov'; MonthNames[11] = 'Dec'; break; case "es": DaysOfWeek[0] = "Sunday"; DaysOfWeek[1] = "Monday"; DaysOfWeek[2] = "Tuesday"; DaysOfWeek[3] = "Wednesday"; DaysOfWeek[4] = "Thursday"; DaysOfWeek[5] = "Friday"; DaysOfWeek[6] = "Saturday"; DaysOfWeekS[0] = "Sun"; DaysOfWeekS[1] = "Mon"; DaysOfWeekS[2] = "Tue"; DaysOfWeekS[3] = "Wed"; DaysOfWeekS[4] = "Thu"; DaysOfWeekS[5] = "Fri"; DaysOfWeekS[6] = "Sat"; MonthNames[0] = 'Jan'; MonthNames[1] = 'Feb'; MonthNames[2] = 'Mar'; MonthNames[3] = 'Apr'; MonthNames[4] = 'May'; MonthNames[5] = 'Jun'; MonthNames[6] = 'Jul'; MonthNames[7] = 'Aug'; MonthNames[8] = 'Sep'; MonthNames[9] = 'Oct'; MonthNames[10] = 'Nov'; MonthNames[11] = 'Dec'; break; default: DaysOfWeek[0] = "Sunday"; DaysOfWeek[1] = "Monday"; DaysOfWeek[2] = "Tuesday"; DaysOfWeek[3] = "Wednesday"; DaysOfWeek[4] = "Thursday"; DaysOfWeek[5] = "Friday"; DaysOfWeek[6] = "Saturday"; DaysOfWeekS[0] = "Sun"; DaysOfWeekS[1] = "Mon"; DaysOfWeekS[2] = "Tue"; DaysOfWeekS[3] = "Wed"; DaysOfWeekS[4] = "Thu"; DaysOfWeekS[5] = "Fri"; DaysOfWeekS[6] = "Sat"; MonthNames[0] = 'Jan'; MonthNames[1] = 'Feb'; MonthNames[2] = 'Mar'; MonthNames[3] = 'Apr'; MonthNames[4] = 'May'; MonthNames[5] = 'Jun'; MonthNames[6] = 'Jul'; MonthNames[7] = 'Aug'; MonthNames[8] = 'Sep'; MonthNames[9] = 'Oct'; MonthNames[10] = 'Nov'; MonthNames[11] = 'Dec'; } function init(){ getTime(); //setTimeout("getTime()", 5000); } function getTime() { Digital = new Date(); hours = Digital.getHours(); minutes = Digital.getMinutes(); month = MonthsOfYear[Digital.getMonth()]; date = Digital.getDate(); day = Digital.getDay(); year = Digital.getFullYear(); var now = new Date(); var now_hours, now_minutes, old_hours, old_minutes, timeOld = ''; now_hours = now.getHours(); now_minutes = now.getMinutes(); if (ampm) { var am_pm = now_hours > 11 ? 'pm' : 'am'; now_hours = ((now_hours > 12) ? now_hours - 12 : now_hours); document.getElementById('iap').src = 'images/clock/' + am_pm + '.png'; } now_hours = ((now_hours < 10) ? "0" : "") + now_hours; now_minutes = ((now_minutes < 10) ? "0" : "") + now_minutes; date = ((date < 10) ? "0" : "") + date; // data - verificar formato: dd/mm/yyyy ou yyyy/dd/mm ou outro //currDate = date + "/" + month + "/" + year; /* dd/mm/aaaa Fri 23 Apr 2010 mm/dd/aaaa Fri Apr 23 2010 aaaa/mm/dd 2010 Apr 23 Fri aaaa/dd/mm 2010 23 Apr Fri */ currDate = Digital.toLocaleDateString(); var ary = new Array(); ary = currDate.split(" "); if(isNaN(ary[0])){ currDate = DaysOfWeekS[day]+', '; if(isNaN(ary[1])){ currDate += MonthNames[Digital.getMonth()] + ' ' +date+', '+year; }else{ currDate += date + ' ' + MonthNames[Digital.getMonth()] + ' ' + year; } }else{ if(isNaN(ary[1])){ currDate = year + ' ' + MonthNames[Digital.getMonth()] + ' ' + date + ', ' + DaysOfWeekS[day]; }else{ currDate = year + ' ' + date + ' ' + MonthNames[Digital.getMonth()] + ', ' + DaysOfWeekS[day]; } } timeOld += '<div id="hours"><div class="line"></div>'; timeOld += '<div id="hours_bg">'; timeOld += '<img id="hours_bg1" src="images/clock/clockbg1.png" /></div>'; timeOld += '<img src="images/clock/clockbg-blank.png" id="fhd" class="first_digit" />'; timeOld += '<img src="images/clock/clockbg-blank.png" id="shd" class="second_digit" />'; timeOld += '</div>'; timeOld += '<div id="minutes"><div class="line"></div>'; if (ampm) { timeOld += '<div id="am_pm"><img src="images/clock/apm.png" /></div>'; } timeOld += '<div id="minutes_bg"><img id="minutes_bg1" src="images/clock/clockbg1.png" /></div>'; timeOld += '<img src="images/clock/clockbg-blank.png" id="fmd" class="first_digit" />'; timeOld += '<img src="images/clock/clockbg-blank.png" id="smd" class="second_digit" />'; timeOld += '</div>'; document.getElementById('clock').innerHTML = timeOld; document.getElementById("date").innerHTML = currDate; document.getElementById('fhd').src = 'images/clock/' + now_hours.substr(0,1) + '.png'; document.getElementById('shd').src = 'images/clock/' + now_hours.substr(1,1) + '.png'; document.getElementById('fmd').src = 'images/clock/' + now_minutes.substr(0,1) + '.png'; document.getElementById('smd').src = 'images/clock/' + now_minutes.substr(1,1) + '.png'; //setTimeout("getTime()",(60 - now.getSeconds()) * 1000); setTimeout("getTime()", 4000); } function GetLanguage(){ try { return widget.sysInfo.getLanguage(); }catch(E){ return "pt"; } } Hi I've managed to change the border color whenever someone clicks on another link on my page but because I need to use return false to keep the color it is stopping the link from going to that page; Code: <script type="text/javascript"> function changeColor(color) { document.getElementById("nav").style.borderColor = color; } </script> <a href="index.php" onclick="changeColor('red') ;return false">HOME</a> <a href="about.php" onclick="changeColor('blue') ;return false">ABOUT</a> <a href="contact.php" onclick="changeColor('orange') ;return false">CONTACT</a> Any help would be appreciated, I've only recently got into JS Cheers Hi all, I have a page built with asp.net that includes some "imagebutton"s within a form. These render as input tags with the type set to image. I ahve the onclick attribute set to run a custom javascript function and return false, so in the fully rendered page I get something like the following: Code: <input type="image" name="ctl00${cut}" tabindex="-1" title="Click to look up the details" src="images/load_details.png" onclick="LoadDetails(); return false;" style="border-width:0px;" /> This has worked fine for the few months the code has been in place and then just recently (within the last few days) it has stopped working for a single network user. They click on the link and instead of the function executing (and the AJAX loading details into the page) the form submits. This makes me think that the "return false" simply isn't executing. The user says that they haven't changed any settings or anything that may cause this issue... The browser being used throughout the company is IE8 under Windows XP. I have checked the version being used on their comptuer and it is 8.0.6001.18702, which is the same version as the one installed on my local machine... which is working fine. Another user has logged into the computer being used by the user with the issues and it works fine for the second user. Also, the user having the issues has logged into a different computer on the network and was still having the same problems. I think I've included all the details, but I'll happily provide any required information. Anyone have any ideas? |