Jump to content

wychegnome

Members
  • Posts

    16
  • Joined

  • Last visited

Everything posted by wychegnome

  1. At least I think it is a timing issue but I could be wrong. I have a web page that loads an Ordnance Survey (UK) map into a window and then needs to add a series of overlays containing my own data. The overlays do not always load with one or all 'missing' when the page is loaded. The situation is worsened when the page is refreshed. And which overlay file(s) is missed seems to vary randomly. <body onLoad="initialiseMap()"> triggers the sequence and the following code forms a part of that sequence: $(document).ready(function(){ var commonOneFile = myMapPath + "common1.js"; var venueFile = myMapPath + "venues.js"; $.getScript(commonOneFile, function() { }); $.getScript(venueFile, function() { });// and load selective markers and lines if we have a file name to work from if (myFileName.length > 2) { var commonTwoFile = myMapPath + "common2.js"; var linesFile = myMapPath + myFileName + "lines.js"; var markersFile = myMapPath + myFileName + "markers.js"; $.getScript(commonTwoFile, function() { }); $.getScript(linesFile, function() { }); $.getScript(markersFile, function() { }); } }); // end of document.ready function The files must be called in the sequence shown as the content of the second file is dependent on the content of the first one and so on. The last two must follow as fourth and fifth but can be in either order. I have tried both with and without using the document.ready function and the results are much the same either way. It also seems to make no difference whether I call these overlay scripts before or after the map is created. Is there a better or more reliable way of ensuring all the (two or five) required javascript files are fully read in the correct sequence before the map page is presented to the user? Thanks
  2. Thank you for your help - a long question and a short reply. Now working, thank you again.
  3. I am struggling with trying to get two sets of validation to work together on a form. The main set of validation is set up using Dreamweaver 8 and that provides these two scripts which sit in the header section of the page: <script type="text/JavaScript">function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document); if(!x && d.getElementById) x=d.getElementById(n); return x;} function MM_validateForm() { //v4.0 var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args); if (val) { nm=val.name; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+' must contain a number.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'R') { if (nm == "recaptcha_response_field") { errors += '- Anti Spam Test must be completed.\n'; } else errors += '- '+nm+' required please.\n'; } } } if (errors) alert('Please correct the following error(s):\n'+errors); document.MM_returnValue = (errors == '');}</script>In the second of the scripts I have successfully added additional validation to pick up that the reCaptcha field hasn't been completed. The validation is invoked using the form's onsubmit function: <form method="post" action="file.asp" onsubmit="MM_validateForm('firstName','','R','lastName','','R','address1','','R','city','','R','zip','','R','email','','RisEmail','email2','','RisEmail');return document.MM_returnValue"> (the arguments are in sets of three which it why it looks odd, the sets of three are 1. input field name, 2. unknown but not used, and 3 the settings to check for). I have a separate script which also resides in the header section: <script type="text/javascript">function checkEmail(theForm) { if (theForm.email.value != theForm.email2.value) { alert('eMail addresses don\'t match!'); return false; } else { return true; }}</script> This is designed to compare the content of two input fields and return an alert message if they don't match. If I invoke the email checker using the form's onsubmit function in place of the Dreamweaver scripts it works as intended. However, if I use it in the email2 input field either in the form onblur="checkEmail(this);" or onchange="checkEmail(this);" or onsubmit="checkEmail(this);" in conjuction with the Dreamweaver supplied code located in the form's onsubmit instruction it fails to activate and no error is generated when email and email2 fields hold differing contents. In essence this works:<form method="post" action="file.asp" onsubmit="MM_validateForm('firstName','','R','lastName','','R','address1','','R','city','','R','zip','','R','email','','RisEmail','email2','','RisEmail');return document.MM_returnValue"> so does this:<form method="post" action="file.asp" onsubmit="checkEmail(this);"> but this combination doesn't:<form method="post" action="file.asp" onsubmit="MM_validateForm('firstName','','R','lastName','','R','address1','','R','city','','R','zip','','R','email','','RisEmail','email2','','RisEmail');return document.MM_returnValue"><input name="email" type="text" /><input name="email2" type="text" onblur="checkEmail(this);" /> What I need to do is check the form on a single press of the submit button to validate that the 'required' fields have entries and they of the correct type (text, number, email etc) and that the two email fields contain identical entries so as to minimise the risk of a mis-typed email address. Any help of guidance on how to merge the two varities of checking would be appreciated. Thanks, John
  4. I am struggling to understand the proper positioning of the global.asa file on an existing web site to which I am adding a shopping cart facility. Currently I have a global.asa file sitting in the root directory of the web site which contains just one item in the 'Session_OnStart' sub routine to set a security level for acess. In the same root directory there is a .asp page which, on successful login, changes the session security level and alters the timeout period from the default of 20 minutes to allow logged in users adequate time to browse the shop. Also in the same root directory are a number of contact form asp pages but these do not amend the security level - they have no need to. At this moment I should point out that browsing the site does not require users to login, but they will need to in order to claim discounts on purchases. The shopping cart part of the web site is being developed from a commercially available one and is based round an Access database. The authors (and copyright holders) supply the system with a license that permits substantial customisation to integrate with an existing site. With their system comes a global.asa file which contains entries for the 'application_OnStart', 'session_OnStart', and 'session_OnEnd' sub routines but, suprisingly, nothing for the 'application_OnEnd' sub routine. The shopping cart asp pages are being located in a Shop sub-directory of the web site so as to keep them segregated from pages not relevant to the shop. The shop page files in the Shop directory are all named with a .asp name. The instructions from the cart supplier clearly states "The global.asa file needs to be in the root directory of the MetaCart ASP web application." Now comes the point where confusion sets in. On http://www.w3schools...p_globalasa.asp it clearly states "The Global.asa file must be stored in the root directory of the ASP application, and each application can only have one Global.asa file." On http://msdn.microsof...v=vs.90%29.aspx there appears this statement: "An ASP-based application is made up of all the files in the application's root directory and any subdirectories. An application starts the first time that a user opens one of the Web pages in the application and ends when the server shuts down." On http://www.haneng.com/lessons_19.asp the author states "Can you have multiple Global.asas? Yes you can, but only one in each directory." He also says "The first problem is that the Application_OnEnd script doesn't run. At least nobody that I have talked two have managed to get it to work." So, the multiple questions: 1. Where the .asp pages comprising something such as a shopping cart system are placed in a sub-directory of the main web site does the entire web site or just the sub-directory constitute "the ASP application" or "Application Root"? 2. Should the cart supplier's global.asa file be in the root directory of the web site or in the 'cart application root directory' which is a sub-directory of the complete web site? 3. What happens of the cart system global.asa file sits in the shop directory and the existing one remains in the site root directory? 4. If only one global.asa file should exist for the whole web site including the shop (it's easy enough to merge the two sets of information), should it be in the site root or the shop directory? 5. If in the shop directory, how do I ensure that the login process (which runs in the web site root) picks up the session security initial setting from a global.asa file residing in a sub-directory? 6. The main part of the web site consists of .html files. Do these pay any regard to the global.asa file as a visitor to the site will only encounter the shop files by using the menu structure of the web site (unless they have bookmarked the shop page)? 7. Several definitions mention the web-server shutting down. Does this literally mean shutting down (power switched off) or just that the last user has exited and the shop files and database files on the web server are not now being accessed by anyone? 8. Does 'application_'onEnd' work assuming some correct code has been entered in the sub-routine? 9. What happens if a user has cookies disabled on their browser? Sorry it's a long one, but I could do with some plain and simple explanations. Thanks.
×
×
  • Create New...