JavaScript - Native Pointers
why doesn't this work?
Code: var d=document.getElementsByTagName; alert(d); //looks ok here alert( d("body") ); //fails Similar TutorialsIs there a way to circle trough the native properties (constructor, prototype, length) of an Array object? Obviously, a simple for(a in array) won't do the trick.
Its me again .. I am using the jquery script to allow users in select a calender date from the a popup window. however, when selected, the calender is being displayed underneath the popup windows and not on top. any ideas or pointer on this one as its driving me mad, i've been trying to fix it since 7:30am and still no further forward. please help, many thanks. So I am working on a project that converts fahrenheit to celcius, or the other way around. So when I click on the radio button for fahrenheit to celcius, it disables the celcius textbox, and the celcius to fahrenheit radio button disables the fahrenheit text box. What I can't figure out is how to get my radio buttons to reset the form to be able to enter another conversion to be made. What it does is locks up both text boxes so that I can't enter anything at all after the first time I do it. Code: <body> <div id="content"> <h1>Convert temperature</h1> <input type="radio" onclick="reset();document.getElementById('degrees_celcius').disabled=this.checked" name="conversion_type" id="to_celcius" />From Fahrenheit to Celcius<br /> <input type="radio" onclick="reset();document.getElementById('degrees_fahrenheit').disabled=this.checked" name="conversion_type" id="to_fahrenheit" />From Celcius to Fahrenheit<br /> <br /> <form id="foofoo"> <label>Degrees Fahrenheit:</label> <input type="text" id="degrees_fahrenheit" class="disabled" /><br /> <label>Degrees Celcius:</label> <input type="text" id="degrees_celcius" class="disabled"/><br /> <br /> </form> <input type="button" id="convert" value="Convert" /><br /> <br /> </div> </body> Code: var temperature = function (){//This f if($("to_celcius").checked == true) { var far = parseFloat($("degrees_fahrenheit").value ); if(isNaN(far)) { alert("Please enter a valid temperature.") return; } var far_cel =Math.round((far-32) * 5/9); $("degrees_celcius").value = far_cel; }else ($("to_fahrenheit").checked ==true) { var cell = parseFloat($("degrees_celcius").value); if(isNaN(cell)) { alert("Please enter a valid temperature.") return; } var cel_far = Math.round(cell * 9/5 + 32); $("degrees_fahrenheit").value = cel_far; } } function reset()//resets the text box fields { $("foofoo").reset(); } window.onload = function(){ $("convert").onclick = temperature; $("to_fahrenheit").onclick = reset; $("to_celcius").onclick = reset; } I was wondering if there are any sites dedicated to ending javascript objects using the prototype property to give them features like trimming string, removing elements of arrays by name, removing duplicates in arrays, etc. Granted I have functions to do this but there's probably a ton of other good ones out there. Most things I've seen are frameworks like JQuery (which is awesome) but it doesn't extend these objects.
Well just came to notice this lack of tools on javascript to manage uploads or downloads while working on my new project. I've been trying different ways to get the upload progress, stimated time left, upload speed average, but everything I have done was somehow dirty. I have spent the last two days trying to get a flash file do this for me, and there is always an issue and you have to get a tricky solution to get something that should be a native javascript support at this age of the web. What do you think guys, isn't the web mature enought to get a decent upload / download progress functions? What are big guys doing, youtube, google, flickr? Code: function sortArrayGo(startingArray, sortNum) { var holder = startingArray; //holder.push(startingArray[0]); var sortedArray = new Array(); var endNum = startingArray.length; //indexPlace=0; for(n = 0; n < endNum; n++) { var min = 0; for(m=1; m<holder.length; m++) { alreadyMin = holder[min][sortNum]; possibleMin = holder[m][sortNum]; if(alreadyMin > possibleMin) { min = m; } } thisLine = startingArray.splice(min, 1); for(cellCount = 0; cellCount < tablePos.length; cellCount++) { colNum = tablePos[cellCount]; dataToInsert = thisLine[colNum]; document.getElementById('dataTable').rows[n].cells[cellCount].innerHTML = dataToInsert; } sortedArray.push(thisLine); } return sortedArray; } i'm sorting a 2d array by whatever column i specify. i know from using firebug that my sorting is working, but it's getting and displaying undefined for dataToInsert and inside of my table, but sortedArray winds up sorted correctly. |