Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Monday, April 20, 2009

_f is undefined

I was getting the above error in my firebug output. It was coming from an included template that I use elsewhere on the website and I couldn't figure it out. Turns out that the page from where the cfwindow is called had a form without a name and id on it. Once I gave the cfform a name and id the problem went away and it works now.

Monday, April 13, 2009

javascript function not found and cutting corners on code

I got hungup for several hours this afternoon on a couple of stupid issues. The first, I was getting a memory leak error and my browser was freezing up so that sometimes I had to restart. Turns out I did something I do alot in coldfusion, I included the end tag of a javascript tag in the emain tag like this:




I don't know why this is but I am sure there is an easy explanation that should make sense to me, but It didn't.

The other thing that took alot longer to figure out was a cfwindow that wasn't findinng the above attached .js file. I played around with the path and all sorts of stuff and couldn't figure out why it wasn't working. Because that script tag above has to be on the parent page that calls the cfwindow, not on the page that comes up inside the cfwindow.

Tuesday, May 08, 2007

Use a javascript confirm box to ask the user if they want to delete.

Found this here: http://psacake.com/web/iw.asp

Wednesday, December 13, 2006

My users have been requesting a seemingly simple feature for a while now and I could not get it to work.
 
When they enter a value, they are prompted with a javascript confirm (Ok/Cancel) box if the value is over $1,000,000.  If the choose "OK", no problem.  But when they choose cancel, they wanted to be put back in that same field.  I should just be able to do the following:
 

function checkValue(){

if (document.getElementById('valuation ').value >= 1000000){

if (confirm("This value is over $1,000,000. Are you sure you meant to enter such a large value?")){

}

else {

document.getElementById('valuation').focus();

}

return false;

}

}

I was able to set focus to any field, except the one I just came from.  The only hack I was able to find was to set focus first to another field, then the field I came from and then use the follwing in my <input> statement.  

onFocus="this.select()"

Here is the javascript function I had to use:

function checkValuation(){

if (document.getElementById('valuation').value >= 1000000){

if (confirm("This value is over $1,000,000. Are you sure you meant to enter such a large value?")){

}

else {

document.getElementById('otherfield').focus();

document.getElementById('valuation').focus();

}

return false;

}

}

 
-------------------------------
David Mineer

Friday, November 03, 2006

I was changing around some javascript on one of my pages and came to a piece where I wanted to access a variable several times. I remembered using a "with" statement when doing some programming Visual Basic for Access. I looked up the with statement and found out that it is not recommended to use.


alert(document.title);
alert(document.body.tagName);
alert(document.location);


Here is the with Statement:


with (document) {
alert(title);
alert(body.tagname);
alert(location);
}



"It is another scope. When you use the with statement, you are forcing the interpreter to not only look up the scope tree for local variables, but you are also forcing it to test each variable against the object specified to see if it's a property" - "Professional Javascript for Web Developers, Nicholas C Zakas, p 581

Friday, October 27, 2006

Trying to a seemingly simple thing before going live with the AJAX code I have been working on. I don't want pressing the enter key to submit the form when a field is in a particular field. This turned out to be harder than I thought. But here is the code that does it:

Include the following element into the head part of your document:

/script type="text/javascript"/
function noenter() {
return !(window.event && window.event.keyCode == 13); }
/script/

Add the following attribute into each input type="text" tag(s) in your form:
onkeypress="return noenter()"

The function has to go in the header on the page. It didn't work for me putting it in an included .js file.