Write For Us

Web Development Primer for PL/SQL Programmers - Introducing JavaScript

E-Commerce Solutions SEO Solutions Marketing Solutions
832 Views
Published
Now let's go on here. I mentioned that I'd show you how to debug JavaScript. Most of you PL/SQL programmers are very familiar with the concept of debugging from your experience with things like SQL developer and TOAD that will allow you to inspect your PL/SQL code and allow you to set break points and then single step through your code and inspect the individual values of your variables, kind of where your sins are in your code.

Of course, JavaScripts, these tools have exactly the same concept. I'm sorry. I don't have to dwell on that too much. The trick here is A, you need to know that it does exist, which I'm just telling you now, and then you have to figure out where to find it. I've got a little example here so we can see it in action. A very simple theme - I could build a function called dividemembers. It just takes a numerator and a denominator, that's the division, and pops the result into a variable called vResult and then displays that on the page.

Then you have some HTML down here and you can see up here that when I get the value of the numerator into the variable, there's a little piece of syntax. Here is it says, "Get element by ID," and of course the ID is a numerator and you can see I've got an input down here with this ID trick here so that the ID is numerator. That shows you how this ID business is used to tie the JavaScript to the HTML - very important concept here.

And then we got two inputs, one for numerator and one for denominator. Here I actually put the result into a paragraph tag and it too has an ID of result. It's a paragraph on the page and we'll change this "And the answer is..." to whatever the result is from the division.

Of course, to fire this function, we got a button to find. That button has an on-click event defined for it and that on click event happens to be the name of our JavaScript function. That's how the JavaScript function gets fired when we press the button.
Category
Success
Sign in or sign up to post comments.
Be the first to comment