Friday, November 19, 2010

How do I get Javascript and HTML to communicate?

Is there any way for me to take an input box value in HTML, and use it in Javascript?How do I get Javascript and HTML to communicate?
Several ways depending on what you are trying to do and how. No code given so not gonna guess.



RonHow do I get Javascript and HTML to communicate?
It's called the DOM, Document Object Model.



Basically Javascript can call just about any property, value, position, anything from HTML.



If you want a form field value easy:

document.form_id.field_name.value



Want to change the color of a font:

document.getElementById('element_id').?=';#fff';;



Change the text of a link:

document.getelementById(';link_id';).inn?= ';New Link';;



And the best part about the DOM is that it is logically written. If you think you can write something you probably can. Just look at my examples.
Inside the %26lt;script%26gt; element write the code of the javascript function and place the document design in the %26lt;body%26gt; tag.



This site helps you more to learn about the javascript and html easier.



http://www.w3schools.com/js/js_examples_
That's not really possible. I've tried. But if your looking for HTML stuff go to justin-productions.webs.com. They say they have some good html, but I dont see sum, but if you request for html they give it to you via email.
%26lt;form name=';form1'; onchange=';func1();';%26gt;

%26lt;input type=';text'; name=';val1';%26gt;%26lt;/input%26gt;

%26lt;/form%26gt;



in js:

function func1() {

if (document.form1.val1.value == ';something';) {

...

}

...

}



hope this helps
  • pencil cases with initial
  • Cute duvet covers
  • No comments:

    Post a Comment