I am trying to test my variables in Javascript, but when I use the window.alert(variable); it pops up undefined.

I believe I declared the scope right, and yet this issue. Am I calling the element incorrectly in the function?

Webpage attached with HTML, CSS and images.
  • 6 KB
  • Problem Page

    asked 11/28/2011 01:38

    athomsfere's gravatar image

    athomsfere ♦♦

    4 Answers:
    I've changed it slightly just check it..


    manjunathub's gravatar image


    You have a variable called "title", you have a function called "title" as well. That is confusing. It doesn't works.
    Besides that, in your function title (that you could change its name to "myTitle" for example for it to work) you're searching an item by ID but that tag doesn't has an ID just a NAME...
    changing the function name to "myTitle"
    changing your <input type ... > from name="titleName" to id="titleName" and obviously the function calling to the new name "myTitle" will be fine
    In your calcPay function you're trying to display the innerHTML of an input type text tag, so it will never work, change it for "value" instead

    answered 2011-11-28 at 10:05:50

    baretree's gravatar image


    Oh, and by the way.. if you change the name of your variable to something different, like varTitle (to avoid conflicts) then on your calcPay function you can simply do your alert(varTitle); and it will show the value you assigned to it on the onBlur event to the Title box :)

    answered 2011-11-28 at 10:28:55

    baretree's gravatar image


    I followed these directions and with a little tinkering I got it to work.


    answered 2011-11-28 at 10:31:43

    athomsfere's gravatar image


    Your answer
    [hide preview]

    Follow this question

    By Email:

    Once you sign in you will be able to subscribe for any updates here

    By RSS:


    Answers and Comments



    Asked: 11/28/2011 01:38

    Seen: 221 times

    Last updated: 11/28/2011 06:37