mdupras Posted June 22, 2010 Report Share Posted June 22, 2010 Hi all -- I have a real estate transactions database that allows users to search date ranges and selling price ranges. When I first created the Caspio datapage, I wrote Javascript that prefills the date range and also checks for input errors when the user chooses a new date range or sale price range. If the user chooses a "from" date that comes chronologically after the "to" date, they immediately get an error message when they click off the input box and the dates are re-set to the default settings. Same when they're selecting a price range from the drop-down menus: if they choose a starting value higher than the ending value, they get an error alert and the range is re-set to the default. As an extra check, the script also checks for comparison errors when the form is submitted and doesn't submit if there's an error. At least, that's what's supposed to happen ... All of this was working beautifully at one time, but I just discovered that somewhere along the line, the code stopped working, and I can't figure it out. There's too much code to paste it all here, but here's an example portion -- this checks the selected sale price range for errors: function checkPriceLow() { var startPriceLow = document.getElementById('caspioform').Value6_1.value; var endPriceLow = document.getElementById('caspioform').Value6_2.value; var minPriceLow = parseInt (startPriceLow); var maxPriceLow = parseInt (endPriceLow); if (minPriceLow > maxPriceLow) { alert("Minimum price must be lower than maximum price. Please make another selection."); document.getElementById('caspioform').Value6_1.value=0; } } function checkPriceHigh() { var startPriceHigh = document.getElementById('caspioform').Value6_1.value; var endPriceHigh = document.getElementById('caspioform').Value6_2.value; var minPriceHigh = parseInt (startPriceHigh); var maxPriceHigh = parseInt (endPriceHigh); if (minPriceHigh > maxPriceHigh) { alert("Maximum price must be higher than minimum price. Please make another selection."); document.getElementById('caspioform').Value6_2.value=999999999; } } document.getElementById('caspioform').Value6_1.onchange=checkPriceLow; document.getElementById('caspioform').Value6_2.onchange=checkPriceHigh; Here's the direct link to the Caspio datapage I tried changing references such as "document.getElementById('caspioform').Value6_2.value" to "document.getElementById("Value6_2").value" but that didn't work. Any ideas? I'm stumped. As I said, at one time, this code was working just fine. I can't imagine what would have changed ... Thanks! -- Mike Quote Link to comment Share on other sites More sharing options...
bahar_vm Posted June 23, 2010 Report Share Posted June 23, 2010 Hi, I recommend if you use firefox browser and install firebug add-on which is free to download. This way you can see if there is any error in your scripts. I see an error: document.getElementById("a1") is null [break on this error] document.getElementById("a1").onclick = dateClickStart; One error prevents the rest of the code to be executed so you need to make sure to correct all the errors that you can catch using firebug. Hope this helps. Best, Bahar M. Quote Link to comment Share on other sites More sharing options...
mdupras Posted June 23, 2010 Author Report Share Posted June 23, 2010 Thanks! I do have Firebug but must not be too savvy with it as I haven't been able to figure out how to get it to show me script errors! At any rate, you're right: When I remove this bit of code, the rest of it works: function dateClickStart () { document.getElementById('caspioform').Value5_1.focus(); if (document.getElementById) {if(document.getElementById('Value5_1')!= null){ try {v_cal.select(document.getElementById('Value5_1'),'a1','MM/dd/yyyy');return false;} catch (e) {}}}; } function dateClickEnd () { document.getElementById('caspioform').Value5_2.focus(); if (document.getElementById) {if(document.getElementById('Value5_2')!= null){ try {v_cal.select(document.getElementById('Value5_2'),'a2','MM/dd/yyyy');return false;} catch (e) {}}}; } document.getElementById("a1").onclick = dateClickStart; document.getElementById("a2").onclick = dateClickEnd; Trouble is, I can't remember what this code does exactly or where I got it! I do know that the error messages with the calendar aren't working exactly correctly. Any clues? Thanks! -- Mike 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.
Note: Your post will require moderator approval before it will be visible.