JavaScript - Javascript - Increment Of Ip Address
Hello.
Is the any chance to increment IP address in Javascript ? For example 11.12.13.14 plus 1 will be 11.12.13.15 I've started to modify my old script: Code: var ipa = 10.11.12.13; var partsa = []; var tempa = ipa; for ( var p = 0; p < 3; ++p ) { var dot1t = tempa.indexOf("."); partsa[p] = tempa.substring(0,dot1t); tempa = tempa.substring(dot1t+1); } partsa[3] = tempa; But do not know how to display ip like: ( parts1[0].parts1[1].parts1[2].parts1[3]+1 ) Please help. Leos Similar TutorialsHi all, I use a javascript to generate a checkbox list. It works well but all the <input type="checkbox"> generated have the same id. I would like to find a way to auto-implement the id (with a unique id). So if my javascript generates 10 checkboxes, I will get id from 1 to 10 or something similar. Code: // here I build the filter checkboxes based on all the class names $.each(arrayUniqueClasses, function() { $('<li><input class="styled" type="checkbox" checked="checked" name="1" value="'+this+'" id="1" /> <label class="check" for="1"></label> <label class="info" for="filterID'+this+'">'+this+'<\/label><\/li>').appendTo('ul.filters'); }); so I tried something but it doesn't work at all (I'm a beginner as you can guess) : Code: var getUniqueId = (function () { var id=0; return function() { if (arguments[0]==0) id=0; return id++; } } )(); Thanks for helping here the full script if needed : Code: function unique(a) { tmp = new Array(0); for(i=0;i<a.length;i++){ if(!contains(tmp, a[i])){ tmp.length+=1; tmp[tmp.length-1]=a[i]; } } return tmp; } function contains(a, e) { for(j=0;j<a.length;j++)if(a[j]==e)return true; return false; } function removeItems(array, item) { var i = 0; while (i < array.length) { if (array[i] == item) { array.splice(i, 1); } else { i++; } } return array; } $(document).ready(function () { if ($('.filterThis > li').length < 2) { return; } var stringOfClassNames = ''; $('.filterThis > li').each( function (i) { var thisClassString = $(this).attr('class'); stringOfClassNames = stringOfClassNames +' '+ thisClassString }); stringOfClassNames = jQuery.trim(stringOfClassNames); var arrayClasses = stringOfClassNames.split(' '); var arrayClasses = arrayClasses.sort(); totalNumberOfItemsToFilter = $('.filterThis > li').length; var result = new Object(); for (var filterClass in arrayClasses) { if (result[arrayClasses[filterClass]] === undefined) { result[arrayClasses[filterClass]] = 1; } else { result[arrayClasses[filterClass]]++; } } var resultsToRemoveFromFilters = new Array(); for (var item in result) { if (result[item] == totalNumberOfItemsToFilter) { resultsToRemoveFromFilters.push(item); } } arrayUniqueClasses = (unique(arrayClasses)); if (arrayUniqueClasses.length > 1) { $('<ul class="filters"><\/ul>').insertAfter('h3'); $.each(arrayUniqueClasses, function() { $('<li><input class="styled" type="checkbox" checked="checked" name="1" value="'+this+'" id="0" /><label class="check" for="0"></label><label class="info" for="filterID'+this+'">'+this+'<\/label><\/li>').appendTo('ul.filters'); }); var classesStringOfSin = new Array(); classesStringOfSalvation = arrayUniqueClasses; $('.filterThis > li').addClass('filterTriggerShown'); $('.filters input').click( function() { var value= $(this).val(); stringValue = '.filterThis > li.'+value; if ($(this).is(':checked')) { classesStringOfSalvation.push(value); classesStringOfSin = removeItems(classesStringOfSin, value); $(stringValue).removeClass('filterTriggerHidden').addClass('filterTriggerShown').slideDown(); } else { classesStringOfSin.push(value); classesStringOfSalvation = removeItems(classesStringOfSalvation, value); $(stringValue).removeClass('filterTriggerShown').addClass('filterTriggerHidden'); $.each(classesStringOfSalvation, function() { var newStringValue = stringValue+'.'+this; $(newStringValue).removeClass('filterTriggerHidden').addClass('filterTriggerShown'); }); $('.filterTriggerHidden').slideUp(); } }); } }); I want to know how can i make javascript that i can use by run into in address bar.. I just need such javascript that run through address bar. My purpose is How can i check all check box in webpage that do not include all check or uncheck button? Best common example for check all or uncheck all is Quote: <html> <head> <title>Check All</title> <SCRIPT LANGUAGE="JavaScript"> function checkall(formid) { len=formid.ckb.length for(i=0;i<len;i++) { formid.elements.ckb[i].checked=true } } function uncheckall(formid) { len=formid.ckb.length for(i=0;i<len;i++) { formid.elements.ckb[i].checked=false } } </SCRIPT> </head> <body> <CENTER> <FORM NAME="myform"> <INPUT TYPE="checkbox" NAME="ckb"> Checkbox One <BR> <INPUT TYPE="checkbox" NAME="ckb"> Checkbox Two <BR> <INPUT TYPE="checkbox" NAME="ckb"> Checkbox Three <BR> <INPUT TYPE="button" NAME="chka" VALUE="Check All" onClick="checkall(this.form)"> <INPUT TYPE="button" NAME="unchka" VALUE="Uncheck All" onClick="uncheckall(this.form)"> </FORM> </CENTER> </body> </html> Now for above code If there would not have any javascript for select all then how can i use the select all javascript that i can run through address bar. i.e how can i just check all check box by using javascript? hi, how can i get client mac address OR hdd id with javascript for internet explorer? Hey everyone. I need a little help and I'm not an expert by any stretch of the imagination with javascript. I have a simple little code script and I'd like either the onClick function (or the entire code itself, whichever is easiest) to only load once every 24 hours for each IP address. So "123.1.22.333" should only get the effect of this code once every 24 hours regardless if they revisit my site 5 times a day let's say. So here's my little script: Code: <script language="JavaScript"> function goNewWin() { TheNewWin=window.open("http://google.com",'Google','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1'); TheNewWin.blur(); } </script> <body onClick="goNewWin()"> Any help would be very appreciated. Thanks! My source : Code: <html> <head> <title></title> <script type="text/javascript"> function runcode(cwin) { cwin.location.replace("javascript:alert("Loaded complete")"); } function newtab() { win=window.open("http://www.google.com"); setTimeout("runcode(win)",5000); setTiemout("win.close()",7000); } </script> </head> <body> <input type="button" value="Click to open newtab" onclick="newtab()" /> </body> </html> I want after newtab is opened 5s, alert window will be opened with message:"Loaded complete". Then 2s it is closed. But it isn't what I expect. Please fix it for me. Thanks in advance! Hi Friends, I am facing one problem that screw me left and right. Please share me if anyone of you faced this problem and solved already. I am using the below code to assign the javascript function on select on radio button. This may vary based on radio button selection. For some radio button selection the button will be disabled. if(yes) { document.getElementById("Name").href = "javaScript:functionA()"; document.getElementById("Name").onclick = "javaScript:functionA()"; }else { document.getElementById("Name").href = "#"; } This is the code i am using to activate the button or disable the button. For some causes i am getting "javaScript:functionA()" in the address bar instead of calling that java script method. So my new window is not showing me the correct result. Please some one advise me how to solve this problem. Thanks in advance. Regards, Jeva Let me give an example: javascript: var myvar=10; function myfunc(){}; void(0); After excuting the above js source code in the address bar of my browser, I can use window.myvar and window.myfunc() to access myvar and myfunc. This indicates that the above "address-bar javascript code" must have been stored somewhere in the current page. My question is: where is the "address-bar javascript code" stored in the current page? or equivalently, is it possible to retrieve the "address-bar javascript code" by using some other javascript codes? I checked document.childNodes and document.documentElement, but cannot find the javascript source code. Maybe the source code is stored in the window object? How to retrieve it? Thank you very much for the help! Hi there, I would like to validate the email address typed into the prompt message by the user, but to no avail. Can some kind soul help? Code: function addOption() { var new = prompt("Enter New Item:"); if (!new == "") { var answer = confirm ("Are you sure you want to add? ") if (answer)//if answer is true { var lst = document.getElementById('lstBx'); // listbox control id // Now we need to create a new 'option' tag to add to MyListbox for (var i = 0; i < lst.options.length; i++) { arrTexts = lst.options[i].text; if (arrTexts.toLowerCase() == newItem.toLowerCase()) { alert ("That email address is already included in the list - please enter another one."); break; } else { validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i; strEmail = lst.value; // search email text for regular exp matches if (strEmail.search(validRegExp) == -1) { alert('A valid e-mail address is required.\nPlease retry.'); return false; } var optionNew = document.createElement("option"); optionNew.value = new; // The value that this option will have optionNew.innerHTML = new; // The displayed text inside of the <option> tags // Finally, add the new option to the listbox lst.appendChild(optionNew); //sort items in listbox in alpha order arrTexts = new Array(); for(i=0; i<lst.length; i++) { arrTexts[i] = lst.options[i].text; } arrTexts.sort(); for(i=0; i<lst.length; i++) { lst.options[i].text = arrTexts[i]; lst.options[i].value = arrTexts[i]; } } return false; } } } else { if(new == "") { alert("Key something to textbox please."); } else alert("Cancelled."); } } Code: <select id="lstBx" name="listBox" size="6" style="width: 580px;"> <option>a@hotmail.com</option> <option>b@hotmail.com</option> <option>c@yahoo.com</option> <option>d@gmail.com</option> <option>e@ymail.com</option> <option>f@msn.com</option> </select> AC_ActiveX.js & AC_RunActiveContent.js is for java app that detect my client mac address I have java application running on my computer. I've tested on several pc, sometimes it detect the mac address, but sometimes nothing came out. In create_users.php, somehow im not able to store the mac address into a variable..( var mac = getMacAddress(); ) 1) Are my java coding would run on every pc? 2) I'm able to print out the mac address with "document.write(getMacAddress());" but why isit having stored in the variable is an issue? 3) which explorer would be the best to have the java running? IE/FF/Opera? create_users.php PHP Code: <script src="Scripts/AC_ActiveX.js" type="text/javascript"></script> <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script> <!--[if !IE]> Firefox and others will use outer object --> <embed type="application/x-java-applet" name="macaddressapplet" width="0" height="0" code="MacAddressApplet" archive="macaddressapplet.jar" pluginspage="http://java.sun.com/javase/downloads/index.jsp" style="position:absolute; top:-1000px; left:-1000px;"> <noembed> <!--<![endif]--> <!----> <script type="text/javascript"> AC_AX_RunContent( 'classid','clsid:CAFEEFAC-0016-0000-FFFF-ABCDEFFEDCBA','type','application/x-java-applet','name','macaddressapplet','style','position:absolute; top:-1000px; left:-1000px;','code','MacAddressApplet','archive','macaddressapplet.jar','mayscript','true','scriptable','true','width','0','height','0' ); //end AC code </script><noscript><object classid="clsid:CAFEEFAC-0016-0000-FFFF-ABCDEFFEDCBA" type="application/x-java-applet" name="macaddressapplet" style="position:absolute; top:-1000px; left:-1000px;" > <param name="code" value="MacAddressApplet"> <param name="archive" value="macaddressapplet.jar" > <param name="mayscript" value="true"> <param name="scriptable" value="true"> <param name="width" value="0"> <param name="height" value="0"> </object></noscript> <!--[if !IE]> Firefox and others will use outer object --> </noembed> </embed> <script> function getMacAddress(){ document.macaddressapplet.setSep( "-" ); return (document.macaddressapplet.getMacAddress()); } var mac = getMacAddress(); </script> AC_ActiveX.js Code: function AC_AX_RunContent(){ var ret = AC_AX_GetArgs(arguments); AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs); } function AC_AX_GetArgs(args){ var ret = new Object(); ret.embedAttrs = new Object(); ret.params = new Object(); ret.objAttrs = new Object(); for (var i=0; i < args.length; i=i+2){ var currArg = args[i].toLowerCase(); switch (currArg){ case "pluginspage": case "type": ret.embedAttrs[args[i]] = args[i+1]; break; case "data": case "codebase": case "classid": case "id": case "onafterupdate": case "onbeforeupdate": case "onblur": case "oncellchange": case "onclick": case "ondblClick": case "ondrag": case "ondragend": case "ondragenter": case "ondragleave": case "ondragover": case "ondrop": case "onfinish": case "onfocus": case "onhelp": case "onmousedown": case "onmouseup": case "onmouseover": case "onmousemove": case "onmouseout": case "onkeypress": case "onkeydown": case "onkeyup": case "onload": case "onlosecapture": case "onpropertychange": case "onreadystatechange": case "onrowsdelete": case "onrowenter": case "onrowexit": case "onrowsinserted": case "onstart": case "onscroll": case "onbeforeeditfocus": case "onactivate": case "onbeforedeactivate": case "ondeactivate": ret.objAttrs[args[i]] = args[i+1]; break; case "width": case "height": case "align": case "vspace": case "hspace": case "class": case "title": case "accesskey": case "name": case "tabindex": ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1]; break; default: ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1]; } } return ret; } AC_RunActiveContent.js Code: var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; function ControlVersion() { var version; var axo; var e; // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry try { // version will be set for 7.X or greater players axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); version = axo.GetVariable("$version"); } catch (e) { } if (!version) { try { // version will be set for 6.X players only axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); // installed player is some revision of 6.0 // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29, // so we have to be careful. // default to the first public version version = "WIN 6,0,21,0"; // throws if AllowScripAccess does not exist (introduced in 6.0r47) axo.AllowScriptAccess = "always"; // safe to call for 6.0r47 or greater version = axo.GetVariable("$version"); } catch (e) { } } if (!version) { try { // version will be set for 4.X or 5.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); version = axo.GetVariable("$version"); } catch (e) { } } if (!version) { try { // version will be set for 3.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); version = "WIN 3,0,18,0"; } catch (e) { } } if (!version) { try { // version will be set for 2.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); version = "WIN 2,0,0,11"; } catch (e) { version = -1; } } return version; } // JavaScript helper required to detect Flash Player PlugIn version information function GetSwfVer(){ // NS/Opera version >= 3 check for Flash plugin in plugin array var flashVer = -1; if (navigator.plugins != null && navigator.plugins.length > 0) { if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; var descArray = flashDescription.split(" "); var tempArrayMajor = descArray[2].split("."); var versionMajor = tempArrayMajor[0]; var versionMinor = tempArrayMajor[1]; var versionRevision = descArray[3]; if (versionRevision == "") { versionRevision = descArray[4]; } if (versionRevision[0] == "d") { versionRevision = versionRevision.substring(1); } else if (versionRevision[0] == "r") { versionRevision = versionRevision.substring(1); if (versionRevision.indexOf("d") > 0) { versionRevision = versionRevision.substring(0, versionRevision.indexOf("d")); } } var flashVer = versionMajor + "." + versionMinor + "." + versionRevision; } } // MSN/WebTV 2.6 supports Flash 4 else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4; // WebTV 2.5 supports Flash 3 else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3; // older WebTV supports Flash 2 else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2; else if ( isIE && isWin && !isOpera ) { flashVer = ControlVersion(); } return flashVer; } // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) { versionStr = GetSwfVer(); if (versionStr == -1 ) { return false; } else if (versionStr != 0) { if(isIE && isWin && !isOpera) { // Given "WIN 2,0,0,11" tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"] tempString = tempArray[1]; // "2,0,0,11" versionArray = tempString.split(","); // ['2', '0', '0', '11'] } else { versionArray = versionStr.split("."); } var versionMajor = versionArray[0]; var versionMinor = versionArray[1]; var versionRevision = versionArray[2]; // is the major.revision >= requested major.revision AND the minor version >= requested minor if (versionMajor > parseFloat(reqMajorVer)) { return true; } else if (versionMajor == parseFloat(reqMajorVer)) { if (versionMinor > parseFloat(reqMinorVer)) return true; else if (versionMinor == parseFloat(reqMinorVer)) { if (versionRevision >= parseFloat(reqRevision)) return true; } } return false; } } function AC_AddExtension(src, ext) { if (src.indexOf('?') != -1) return src.replace(/\?/, ext+'?'); else return src + ext; } function AC_Generateobj(objAttrs, params, embedAttrs) { var str = ''; if (isIE && isWin && !isOpera) { str += '<object '; for (var i in objAttrs) { str += i + '="' + objAttrs[i] + '" '; } str += '>'; for (var i in params) { str += '<param name="' + i + '" value="' + params[i] + '" /> '; } str += '</object>'; } else { str += '<embed '; for (var i in embedAttrs) { str += i + '="' + embedAttrs[i] + '" '; } str += '> </embed>'; } document.write(str); } function AC_FL_RunContent(){ var ret = AC_GetArgs ( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" , "application/x-shockwave-flash" ); AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs); } function AC_SW_RunContent(){ var ret = AC_GetArgs ( arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000" , null ); AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs); } function AC_GetArgs(args, ext, srcParamName, classid, mimeType){ var ret = new Object(); ret.embedAttrs = new Object(); ret.params = new Object(); ret.objAttrs = new Object(); for (var i=0; i < args.length; i=i+2){ var currArg = args[i].toLowerCase(); switch (currArg){ case "classid": break; case "pluginspage": ret.embedAttrs[args[i]] = args[i+1]; break; case "src": case "movie": args[i+1] = AC_AddExtension(args[i+1], ext); ret.embedAttrs["src"] = args[i+1]; ret.params[srcParamName] = args[i+1]; break; case "onafterupdate": case "onbeforeupdate": case "onblur": case "oncellchange": case "onclick": case "ondblClick": case "ondrag": case "ondragend": case "ondragenter": case "ondragleave": case "ondragover": case "ondrop": case "onfinish": case "onfocus": case "onhelp": case "onmousedown": case "onmouseup": case "onmouseover": case "onmousemove": case "onmouseout": case "onkeypress": case "onkeydown": case "onkeyup": case "onload": case "onlosecapture": case "onpropertychange": case "onreadystatechange": case "onrowsdelete": case "onrowenter": case "onrowexit": case "onrowsinserted": case "onstart": case "onscroll": case "onbeforeeditfocus": case "onactivate": case "onbeforedeactivate": case "ondeactivate": case "type": case "codebase": case "id": ret.objAttrs[args[i]] = args[i+1]; break; case "width": case "height": case "align": case "vspace": case "hspace": case "class": case "title": case "accesskey": case "name": case "tabindex": ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1]; break; default: ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1]; } } ret.objAttrs["classid"] = classid; if (mimeType) ret.embedAttrs["type"] = mimeType; return ret; } I'm super stuck. Is it possible to increment in a for...in loop? This is what I'm trying to do, but the increments aren't happening. Any help or advice is much appreciated!! Code: var i_1 = 3; var i_2 = 8; for (var key in data.id) { if ([key] < '4') { attach_to = '.active'; } else if ([key] > i_1 && [key] < i_2) { attach_to = '.item_' + i_1; } document.write(attach_to + '<br/>' + i_1+ '<br/>'); i_1 + 4; i_2 + 4; } I need to develop this feature for a charity site displays a number that counts up 1 every 15 seconds. This is to show how many times a kid is abused in this country. I've been researching this and haven't been able to find anything helpful yet. I figured this piece of code was a good start: function doSomething() { setTimeout('doSomething()',15000); } Hi again, I have written the follow code. It is meant to (when finished) output a table showing each member of the array PEOPLE. There Income ,there Tax bracket and there finally there total tax paid. The calulations in the if-else statements are correct. I have to create a loop that will go through the if else statements equal to the amount of the people in the array (This is no problem I have done this earlier) My problem is when I try to add each element (PEOPLE) to the table or there indivual tax outcomes. Can I create a loop and increment in the elements each iteration to put on the table?(for there names) As I am not meant to store each iteration,it is to write to the table each time. This is the code I'm working on with out the loop. [CODE]<html> <head> <script> PEOPLE = new Array ('Mr Dobbaleana','David Lai','Richard Watson','Leigh Brookshaw','Stijn Dekeyser'); BRACKET_LIMITS = new Array (0,6000,37000,80000,180000); MIN_TAX = new Array (0.00,0.00,4650.00,17550.00,54550.00); TAX_RATES = new Array (0.00,0.15,0.30,0.37,0.45); var taxBracket =0; var taxToPay =0; document.writeln ('<table border="2">'); document.writeln ('<tr>'); document.writeln ('<th>'+('Name')+'</th>'); document.writeln ('<th>'+('Income')+'</th>'); document.writeln ('<th>'+('Bracket')+'</th>'); document.writeln ('<th>'+('Tax')+'</th>'); document.writeln ('</tr>'); var currentPersonInRow = parseInt(prompt('Enter your income')); if (currentPersonInRow <= BRACKET_LIMITS[1]){ taxBracket=BRACKET_LIMITS.indexOf(0); taxToPay = (currentPersonInRow-BRACKET_LIMITS[0])*TAX_RATES[0]+MIN_TAX[0]; // will give total taxable income } else if (currentPersonInRow<=BRACKET_LIMITS[2]){ taxBracket=BRACKET_LIMITS.indexOf(6000); taxToPay = (currentPersonInRow-BRACKET_LIMITS[1])*TAX_RATES[1]+MIN_TAX[1]; // will give total taxable income } else if (currentPersonInRow<=BRACKET_LIMITS[3]){ taxBracket=BRACKET_LIMITS.indexOf(37000); taxToPay = (currentPersonInRow-BRACKET_LIMITS[2])*TAX_RATES[2]+MIN_TAX[2]; // will give total taxable income } else if (currentPersonInRow<=BRACKET_LIMITS[4]){ taxBracket=BRACKET_LIMITS.indexOf(80000); taxToPay = (currentPersonInRow-BRACKET_LIMITS[3])*TAX_RATES[3]+MIN_TAX[3]; // will give total taxable income } else { taxBracket=BRACKET_LIMITS.indexOf(180000); taxToPay = (currentPersonInRow-BRACKET_LIMITS[4])*TAX_RATES[4]+MIN_TAX[4]; // will give total taxable income } document.writeln ('<tr>'); document.writeln ('<td>'+(PEOPLE[0])+'</td>'); document.writeln ('<td>'+('$')+(currentPersonInRow)+'</td>'); document.writeln ('<td>'+(taxBracket)+'</td>'); document.writeln ('<td>'+('$')+(taxToPay)+'</td>'); document.writeln ('</tr>'); </script> </head> <body> </body> </html> [/ICODE] OK this is the code I wrote and it works but doesnt meet the assigment critera. Code: <html> <head> <script> PEOPLE = new Array ('Mr Dobbaleana','David Lai','Richard Watson','Leigh Brookshaw','Stijn Dekeyser'); BRACKET_LIMITS = new Array (0,6000,37000,80000,180000); MIN_TAX = new Array (0.00,0.00,4650.00,17550.00,54550.00); TAX_RATES = new Array (0.00,0.15,0.30,0.37,0.45); var personZero = parseFloat( prompt ((' Enter income for ')+(PEOPLE[0]),('0.00'))); var personOne = parseFloat (prompt ((' Enter income for ')+(PEOPLE[1]),('0.00'))); var personTwo = parseFloat (prompt ((' Enter income for ')+(PEOPLE[2]),('0.00'))); var personThree = parseFloat (prompt ((' Enter income for ')+(PEOPLE[3]),('0.00'))); var personFour = parseFloat(prompt ((' Enter income for ')+(PEOPLE[4]),('0.00'))); if ((personZero >= BRACKET_LIMITS[0])&&(personZero <= BRACKET_LIMITS[1])) { var cal1= (personZero-BRACKET_LIMITS[0]); var cal2= (cal1*TAX_RATES[0]); var totalTaxPaid = (cal2+MIN_TAX[0]); var taxBracketOfPeople1=0; alert(totalTaxPaid); } if ((personZero >= BRACKET_LIMITS[1])&&(personZero <= BRACKET_LIMITS[2])) { var cal1= (personZero-BRACKET_LIMITS[1]); var cal2= (cal1*TAX_RATES[1]); var totalTaxPaid = (cal2+MIN_TAX[1]); var taxBracketOfPeople1=1; alert(totalTaxPaid); } if ((personZero >= BRACKET_LIMITS[2])&&(personZero <= BRACKET_LIMITS[3])) { var cal1= (personZero-BRACKET_LIMITS[2]); var cal2= (cal1*TAX_RATES[2]); var totalTaxPaid = (cal2+MIN_TAX[2]); var taxBracketOfPeople1=2; alert(totalTaxPaid); } if ((personZero >= BRACKET_LIMITS[3])&&(personZero <= BRACKET_LIMITS[4])) { var cal1= (personZero-BRACKET_LIMITS[3]); var cal2= (cal1*TAX_RATES[3]); var totalTaxPaid = (cal2+MIN_TAX[3]); var taxBracketOfPeople1=3; alert(totalTaxPaid); } if ((personZero >= BRACKET_LIMITS[4])) { var cal1= (personZero-BRACKET_LIMITS[4]); var cal2= (cal1*TAX_RATES[4]); var totalTaxPaid = (cal2+MIN_TAX[4]); var taxBracketOfPeople1=4; alert(totalTaxPaid); } if ((personOne >= BRACKET_LIMITS[0])&&(personOne <= BRACKET_LIMITS[1])) { var cal1= (personOne-BRACKET_LIMITS[0]); var cal2= (cal1*TAX_RATES[0]); var totalTaxPaid1 = (cal2+MIN_TAX[0]); var taxBracketOfPeople2=0; alert(totalTaxPaid1); } if ((personOne >= BRACKET_LIMITS[1])&&(personOne <= BRACKET_LIMITS[2])) { var cal1= (personOne-BRACKET_LIMITS[1]); var cal2= (cal1*TAX_RATES[1]); var totalTaxPaid1 = (cal2+MIN_TAX[1]); var taxBracketOfPeople2=1; alert(totalTaxPaid1); } if ((personOne >= BRACKET_LIMITS[2])&&(personOne <= BRACKET_LIMITS[3])) { var cal1= (personOne-BRACKET_LIMITS[2]); var cal2= (cal1*TAX_RATES[2]); var totalTaxPaid1 = (cal2+MIN_TAX[2]); var taxBracketOfPeople2=2; alert(totalTaxPaid1); } if ((personOne >= BRACKET_LIMITS[3])&&(personOne <= BRACKET_LIMITS[4])) { var cal1= (personOne-BRACKET_LIMITS[3]); var cal2= (cal1*TAX_RATES[3]); var totalTaxPaid1 = (cal2+MIN_TAX[3]); var taxBracketOfPeople2=3; alert(totalTaxPaid1); } if ((personOne >= BRACKET_LIMITS[4])) { var cal1= (personOne-BRACKET_LIMITS[4]); var cal2= (cal1*TAX_RATES[4]); var totalTaxPaid1 = (cal2+MIN_TAX[4]); var taxBracketOfPeople2=4; alert(totalTaxPaid1); } if ((personTwo >= BRACKET_LIMITS[0])&&(personTwo <= BRACKET_LIMITS[1])) { var cal1= (personTwo-BRACKET_LIMITS[0]); var cal2= (cal1*TAX_RATES[0]); var totalTaxPaid2 = (cal2+MIN_TAX[0]); var taxBracketOfPeople3=0; alert(totalTaxPaid2); } if ((personTwo >= BRACKET_LIMITS[1])&&(personTwo <= BRACKET_LIMITS[2])) { var cal1= (personTwo-BRACKET_LIMITS[1]); var cal2= (cal1*TAX_RATES[1]); var totalTaxPaid2 = (cal2+MIN_TAX[1]); var taxBracketOfPeople3=1; alert(totalTaxPaid2); } if ((personTwo >= BRACKET_LIMITS[2])&&(personTwo <= BRACKET_LIMITS[3])) { var cal1= (personTwo-BRACKET_LIMITS[2]); var cal2= (cal1*TAX_RATES[2]); var totalTaxPaid2 = (cal2+MIN_TAX[2]); var taxBracketOfPeople3=2; alert(totalTaxPaid2); } if ((personTwo >= BRACKET_LIMITS[3])&&(personTwo <= BRACKET_LIMITS[4])) { var cal1= (personTwo-BRACKET_LIMITS[3]); var cal2= (cal1*TAX_RATES[3]); var totalTaxPaid2 = (cal2+MIN_TAX[3]); var taxBracketOfPeople3=3; alert(totalTaxPaid2); } if ((personTwo >= BRACKET_LIMITS[4])) { var cal1= (personTwo-BRACKET_LIMITS[4]); var cal2= (cal1*TAX_RATES[4]); var totalTaxPaid2 = (cal2+MIN_TAX[4]); var taxBracketOfPeople3=4; alert(totalTaxPaid2); } if ((personThree >= BRACKET_LIMITS[0])&&(personThree <= BRACKET_LIMITS[1])) { var cal1= (personThree-BRACKET_LIMITS[0]); var cal2= (cal1*TAX_RATES[0]); var totalTaxPaid3 = (cal2+MIN_TAX[0]); var taxBracketOfPeople4=0; alert(totalTaxPaid3); } if ((personThree >= BRACKET_LIMITS[1])&&(personThree <= BRACKET_LIMITS[2])) { var cal1= (personThree-BRACKET_LIMITS[1]); var cal2= (cal1*TAX_RATES[1]); var totalTaxPaid3 = (cal2+MIN_TAX[1]); var taxBracketOfPeople4=1; alert(totalTaxPaid3); } if ((personThree >= BRACKET_LIMITS[2])&&(personThree <= BRACKET_LIMITS[3])) { var cal1= (personThree-BRACKET_LIMITS[2]); var cal2= (cal1*TAX_RATES[2]); var totalTaxPaid3 = (cal2+MIN_TAX[2]); var taxBracketOfPeople4=2; alert(totalTaxPaid3); } if ((personThree >= BRACKET_LIMITS[3])&&(personThree <= BRACKET_LIMITS[4])) { var cal1= (personThree-BRACKET_LIMITS[3]); var cal2= (cal1*TAX_RATES[3]); var totalTaxPaid3 = (cal2+MIN_TAX[3]); var taxBracketOfPeople4=3; alert(totalTaxPaid3); } if ((personThree >= BRACKET_LIMITS[4])) { var cal1= (personThree-BRACKET_LIMITS[4]); var cal2= (cal1*TAX_RATES[4]); var totalTaxPaid3 = (cal2+MIN_TAX[4]); var taxBracketOfPeople4=4; alert(totalTaxPaid3); } if ((personFour >= BRACKET_LIMITS[0])&&(personFour <= BRACKET_LIMITS[1])) { var cal1= (personFour-BRACKET_LIMITS[0]); var cal2= (cal1*TAX_RATES[0]); var totalTaxPaid4 = (cal2+MIN_TAX[0]); var taxBracketOfPeople5=0; alert(totalTaxPaid4); } if ((personFour >= BRACKET_LIMITS[1])&&(personFour <= BRACKET_LIMITS[2])) { var cal1= (personFour-BRACKET_LIMITS[1]); var cal2= (cal1*TAX_RATES[1]); var totalTaxPaid4 = (cal2+MIN_TAX[1]); var taxBracketOfPeople5=1; alert(totalTaxPaid4); } if ((personFour >= BRACKET_LIMITS[2])&&(personFour <= BRACKET_LIMITS[3])) { var cal1= (personFour-BRACKET_LIMITS[2]); var cal2= (cal1*TAX_RATES[2]); var totalTaxPaid4 = (cal2+MIN_TAX[2]); var taxBracketOfPeople5=2; alert(totalTaxPaid4); } if ((personFour >= BRACKET_LIMITS[3])&&(personFour <= BRACKET_LIMITS[4])) { var cal1= (personFour-BRACKET_LIMITS[3]); var cal2= (cal1*TAX_RATES[3]); var totalTaxPaid4 = (cal2+MIN_TAX[3]); var taxBracketOfPeople5=3; alert(totalTaxPaid4); } if ((personFour >= BRACKET_LIMITS[4])) { var cal1= (personFour-BRACKET_LIMITS[4]); var cal2= (cal1*TAX_RATES[4]); var totalTaxPaid4 = (cal2+MIN_TAX[4]); var taxBracketOfPeople5=4; alert(totalTaxPaid4); } </script> </head> <body> <script> document.writeln ('<table border="2">'); document.writeln ('<tr>'); document.writeln ('<th>'+('Name')+'</th>'); document.writeln ('<th>'+('Income')+'</th>'); document.writeln ('<th>'+('Bracket')+'</th>'); document.writeln ('<th>'+('Tax')+'</th>'); document.writeln ('</tr>'); document.writeln ('<tr>'); document.writeln ('<td>'+(PEOPLE[0])+'</td>'); document.writeln ('<td>'+('$')+(personZero)+'</td>'); document.writeln ('<td>'+(taxBracketOfPeople1)+'</td>'); document.writeln ('<td>'+('$')+(totalTaxPaid)+'</td>'); document.writeln ('</tr>'); document.writeln ('<tr>'); document.writeln ('<td>'+(PEOPLE[1])+'</td>'); document.writeln ('<td>'+(personOne)+'</td>'); document.writeln ('<td>'+(taxBracketOfPeople2)+'</td>'); document.writeln ('<td>'+(totalTaxPaid1)+'</td>'); document.writeln ('</tr>'); document.writeln ('<tr>'); document.writeln ('<td>'+(PEOPLE[2])+'</td>'); document.writeln ('<td>'+(personTwo)+'</td>'); document.writeln ('<td>'+(taxBracketOfPeople3)+'</td>'); document.writeln ('<td>'+(totalTaxPaid2)+'</td>'); document.writeln ('</tr>'); document.writeln ('<tr>'); document.writeln ('<td>'+(PEOPLE[3])+'</td>'); document.writeln ('<td>'+(personThree)+'</td>'); document.writeln ('<td>'+(taxBracketOfPeople4)+'</td>'); document.writeln ('<td>'+(totalTaxPaid3)+'</td>'); document.writeln ('</tr>'); document.writeln ('<tr>'); document.writeln ('<td>'+(PEOPLE[4])+'</td>'); document.writeln ('<td>'+(personFour)+'</td>'); document.writeln ('<td>'+(taxBracketOfPeople5)+'</td>'); document.writeln ('<td>'+(totalTaxPaid4)+'</td>'); document.writeln ('</tr>'); document.writeln('</table>'); </script> </body> </html> Hope that wasnt to confusing Thanks heaps Shaynedarcy First off, i have no idea what to do, because when i get beyond the realm of html/css, vb and php (some) i become lost. I hope someone can help me achieve this because i have no idea what i'm doing, and I've been at it for 2 weeks and no money to hire someone to do this for me. If you ever been in my situation, you know exactly how i feel. I have no code of my own to show you, but hope someone can still help me. I'm have a number 0.0000000, and every min i need that number to increase to 0.0000000, than to 0.0000002 and so on and so forth. Every time i click a button, whatever the number has risen to, it will reset it back down to 0.0000000. Can someone help me out with this? Hello to codingforums, This is my beginning posting here as I am mostly reading, compiling and so.. There are multiple forms in the script generated page, that has to update via script url - and the problem is probably looping through form script -so please help with this as only first form submit correctly while other pass value from 1st - need looping method or condition? Code: <SCRIPT language=Javascript> function getMessage(hwm) { loc = './index.php?p=ordersBasket&sOption=add'; jlc = document.getElementById('qty'); jloc = document.getElementById('pid'); nloc = loc+ '&iProduct='+jloc.value+ '&iQuantity='+jlc.value; self.location = nloc; } </SCRIPT> <FORM id="123" name="123"> <input type="button" id="minus" value="-" onClick="qty.value = (qty.value-1)"> <input type="button" value="+" onClick="qty.value = (+qty.value+1)"> <input type="text" size="4" id="qty" name="name" value="3" /> <INPUT TYPE="text" id="pid" VALUE="123" /> <INPUT TYPE="button" value="order" onclick="getMessage(this)"> </FORM> <FORM id="456" name="456"> <input type="button" id="minus" value="-" onClick="qty.value = (qty.value-1)"> <input type="button" value="+" onClick="qty.value = (+qty.value+1)"> <input type="text" size="4" id="qty" name="name" value="3" /> <INPUT TYPE="text" id="pid" VALUE="456" /> <INPUT TYPE="button" value="order" onclick="getMessage(this)"> </FORM> <FORM id="789" name="789"> <input type="button" id="minus" value="-" onClick="qty.value = (qty.value-1)"> <input type="button" value="+" onClick="qty.value = (+qty.value+1)"> <input type="text" size="4" id="qty" name="name" value="3" /> <INPUT TYPE="text" id="pid" VALUE="789" /> <INPUT TYPE="button" value="order" onclick="getMessage(this)"> </FORM> I have modified a free JS function from he http://www.tangorangers.com/examples...post/index.php To dynamically add text fields to the form. My work-in-progress version is he http://jimpix.co.uk/junk/test/6.html On the form, I have a hidden text field: Code: <input type="hidden" name="hiddenCount" value="" /> What I'd like to do is to increment the hiddenCount each time the "Add" fields button is clicked. This is the button: <input id="add_contact()" onclick="add_contact()" value="Add" type="button"> And this is the JS function: Code: var contact_counter = 0; function add_contact() { if (contact_counter < 9) { contact_counter++; var newFields = document.getElementById('add_contact').cloneNode(true); newFields.id = 'contact'; newFields.style.display = 'block'; var newField = newFields.childNodes; for (var i=0;i<newField.length;i++) { var theName = newField[i].name if (theName) newField[i].name = theName + contact_counter; } var insertHere = document.getElementById('add_contact'); insertHere.parentNode.insertBefore(newFields,insertHere); } } I'm new to JS. I could just about edit the JS function to slightly modify it from the tangorangers version (I only changed it v. slightly). To somehow increment the value in the hidden field each time the button is pressed is beyond me though! Any advice much appreciated. Thanks The following code results in the exact same output. Is there an advantage to using i++ over ++i (or visa-versa) in the loop? Code: <script type="text/javascript"> var tarr1 = []; for (var i=0; i<10; i++) { tarr1.push(i); } var tarr2 = []; for (var i=0; i<10; ++i) { tarr2.push(i); } alert(tarr1.join(',')+'\n'+tarr2.join(',')); </script> Similar question for the increment method in the following: Code: <script type="text/javascript"> var tarr1 = []; var i=0; do { tarr1.push(i); i++; } while (i<10); var tarr2 = []; var j=0; do { tarr2.push(j); ++j; } while (j<10); alert(tarr1.join(',')+'\n'+tarr2.join(',')); </script> Hello just a quick problem with a seemingly difficult solution that I'm not aware throughout. What I'm attempting to do is increment a value when the mouse hovers over the element by using this move_right function: Code: function Move_Right( event, element, number) { number++; var elem = document.getElementById(element); elem.style.right = number + "px"; } inside the mouseover event trigger function which I figured out. The problem is it doesn't move incrementally only once every mouse hover no matter the technique of setInterval(); and or setTimeout(); also ontop of this problem I'm getting errors like : 2014-10-12 20:07:57.785Uncaught TypeError: Cannot read property 'style' of null even after the changes I made also after this original function call : This is the current code so far which is different to the previous code above "obviously" : Edit fiddle - JSFiddle Thanks if someone knows the issues here, I hope it makes sense . Example of my problem: HERE The code is derived from a site offering some advice for javascript: HERE The example of mine tries to use an image as hyperlink... and use mouse events for certain actions. Aside from possibly being the worst javascript code humanly possible...once I slaughtered the code from the site mentioned above, I'm not getting how to arrange things so that a mouse over event switches an image , as does mousedn and mouseup, And (and this is the rub for me) repeating the setup in the same way for a list of quicktime video links. I've got it to work for one row in the table I'm using to attempt some kind of formatting. I'm told `css' is a better way for that but I'm completely ignorant about how to use `css'. So, for now I'm using a table to get at the javascript question. The idea is for viewer to see three red dots at the front of each item being offered. Mouseover is supposed to switch to a green arrow... mousedn is supposed to switch to 2 check marks. I wanted the check marks to persist, so for lack of knowing how to accomplish that... I let mouseup call the same image. (the check marks; Maybe just omitting any directive for mouseup would have the same effect?) About the `image persisting after being clicked' question: It is really a separate question so I will probably start a different thread for that. What I've done works for one list item... but fails for more than one. The only active member of the list (2 in my example) is the bottom one. mouse events on the top one are carried out on the bottom one. I tried to just change the name of all variables in the javascript, and the name given in the `img src=' section of the html code, for the second row... but clearly not what is needed. I changed the names shown below by incrementing the number in the names by 1. I've only posted one row's worth but the next row uses the same code with the variables incremented. And hopefully someone will look at the actual example (URL given above) and see the full code. The basic code I've put here for convience.: Code: <table> <tr> <td valign=top > <A href="./t2.html" onMouseOver="return changeImage()" onMouseOut= "return changeImageBack()" onMouseDown="return handleMDown()" onMouseUp="return handleMUp()" ><img name="jsbutton_0" src="./3dots.png" border="0" alt="javascript button"></A> some nice video <SCRIPT language="JavaScript"> var myimgobj_0 = document.images["jsbutton_0"]; function changeImage() { document.images["jsbutton_0"].src= "./aro1r-mo.png"; return true; } function changeImageBack() { document.images["jsbutton_0"].src = "./3dots.png"; return true; } function handleMDown() { document.images["jsbutton_0"].src = "./checks.png"; return true; } function handleMUp() { document.images["jsbutton_0"].src = "./checks.png"; return true; } </SCRIPT> </tr> </td> hello everybody how can I set url in the address without opening the url , just placing ??? i.e : to open a url we use this PHP Code: document.location = 'http://www.codingforums.com/' I wanna show the user that the url is changing in the address bar as typing after it reached the end it will opens the url I don't care for the method of writing the new url in the address bar such as typing or sliding ... etc please tell me how to do this thanks |