AJAX Tutorial: Part#2

Hmmm so you are really crazy about AJAX? I love it, when you say “s”!!!

OKay, so in my previuos tutorial I gave a link in which you enter a zip code value and the values of state and city gets populated without reloading the whole page. Did you really do that? oh great, I must tell you, you have almost mastered AJAX.

Now, lets do some simple coding and make it more impressive.

So, lets add some more lines of code to the output function. And lets try to make a fainting result display.

Fainting the colors of either image, textbox, label or background of document have become common now a days.

All you need to add is to use DHTML code. DHTML, dont panic. Its not tough. Its just the same regular routine job of what you have already mastered.

Only difference being, that the elements of the HTMl are created at runtime. Simple ah? okay.

How do we create any element at runtime?

input1 = document.createElement(‘input’); //defining the element.

input1.class=”faint” // assign a class name

input1.type=’text’; // creating a simple textbox

input1.value=’Hit Me Hard!!!’; // assign some value

Now, we have created a element and gave some property values.

Lets add to our document.

window.document.appendChild(‘input1’);

Hurrah!!!! we have just dynamically created and added a textbox.

The other way of doing the same:

<input type=”text” value=”Hit Me Hard”>

OKay, now we go ahead and create a faint function

<script type=”javascript”>

function Faint() {

var input1 = document.getElementByID(‘faint’); // class name that we just gave in runtime.