ginerjm Posted March 25, 2011 Share Posted March 25, 2011 OK - here is a function I made (cut and pasted essentially) that works great on my laptop. But on my iphone it gives me an error. The error is vague - err.description reports as: "undefined". Here's the code, which as I said works great on ie. Basically it grabs the selected item from a dropdown menu ("curdirs") and copies it (after a little cleanup) onto some other input fields. <script type="text/javascript"> function displayResult() { var x=document.getElementById("curdirs").selectedIndex; var y=document.getElementById("curdirs").options; try { var str = y[x].text; var arstr = str.split(" "); if (arstr.length >1) document.getElementById("mntstsy").checked = true; else document.getElementById("mntstsn").checked = true; str = arstr.shift(); document.getElementById("uid").value =str; document.getElementById("dirstsy").checked = true; document.getElementById("dirstsy").focus(); } catch(err) { txt="There was an error on this page.\n\n"; txt+="Error description: " + err.description + "\n\n"; txt+="Click OK to continue.\n\n"; alert(txt); } } The code gets triggered by the onclick event. I've tried onchange, onblur for the iphone becuase of some posts I read, but all that does is eliminate the error popup - it still doesn't do anything on the iphone. Yes - I have read about the lack of support for the "select" tag on Safari, but I'm hoping someone has this a clue why this js doesn't work. I certainly don't - I have all of 3 days of experience in it! Quote Link to comment Share on other sites More sharing options...
Adam Posted March 28, 2011 Share Posted March 28, 2011 The 'undefined' message is from err.description, because that itself is not defined. Try: txt+="Error description: " + err.message + "\n\n"; Edit Looks like you used a code snippet found on W3Schools - good advise would be not to use that site! Some idiot supposedly capable of teaching people to learn JavaScript has obviously checked the output in their TryIt editor thing, seen the "undefined" message and thought it was on about the undefined function in their example. http://w3fools.com/ Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 28, 2011 Author Share Posted March 28, 2011 Everything I know about the web is from w3schools!!! Without that there is nothingness! where would you suggest I get my nourishment - for js at least? Quote Link to comment Share on other sites More sharing options...
Adam Posted March 29, 2011 Share Posted March 29, 2011 Ha.. To be honest I started with w3schools too. Whenever you want to learn something new with JavaScript though, just search on Google. Read a couple of articles/tutorials from different sites to ensure you're not being taught bad things (this doesn't guarantee it obviously, but it's better), which is more likely to make it sink in hearing several different explanations anyway. It's easy to spot someone who's learnt from W3Schools when they post a problem, because their code contains their crappy snippets. Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted March 29, 2011 Share Posted March 29, 2011 Some good JavaScript resources: https://developer.mozilla.org/en/JavaScript http://docs.jquery.com/Main_Page http://www.amazon.com/Pro-JavaScript-Techniques-John-Resig/dp/1590597273/ref=sr_1_2?s=books&ie=UTF8&qid=1301399245&sr=1-2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.