• Image 1
  • Image 2
  • Image 3
  • Image 4
  • Image 5
  • Image 6
  • Image 7




Thursday, July 12, 2012

TUTORIAL JAVASCRIPT - MANAGE FORM HTML FOR NEWBIE


Hi… Welcome at my site…

Now… In here I want giving you knowledge javascript about “Manage Form”

Ok.. let’s do read it.

A. Manage CheckBox In Javascript

Define manage form is for correct what the chechbox was to fill (check) ?

Sintaks:
checkboxObject.checked = true|false

Example 1:

<html>
<head>We Are Knowledge<br>
<title>Tutorial Javascript - Array</title>
<script>
function a()
{
document.getElementById("x").checked = true
}
function b()
{
document.getElementById("x").checked = false
}
</script>
</head>
<body>
<form>
<input type = "checkbox" id = "x" /> <br>
<input type = "button" onClick = "a()"  value="Check Checkbox" />
<input type = "button" onClick = "b()"  value="Uncheck Checkbox" />
</form>
</body>
</html>


Example 2:
<html>
<head>We Are Knowledge<br>
<title>Tutorial Javascript - Array</title>
<script>
function a()
{
x = document.forms[0].x
y = ""
for (i = 0; i < x.length; ++i)
{
if (x[i].checked)
{
y = y + x[i].value + " "
}
}
document.getElementById("z").value = "You Ordered Coffee with " + y
}
</script>
</head>
<body>
<p>How whould you like your coffee ?</p>
<form>
<input type = "checkbox" name = "x" value = "cream"> With Cream <br />
<input type = "checkbox" name = "x" value = "sugar"> With Sugar <br />
<br />
<input type = "button" onClick = "a()" value = "send order"> <br /> <br />
<input type = "text" id = "z" size = "40">
</form>
</body>
</html>


B. Manage CheckBox In Javascript

Example 3:

<html>
<head>We Are Knowledge<br>
<title>Tutorial Javascript - Array</title>
<script>
function a(b)
{
document.getElementById("c").value = b;
}
</script>
</head>
<body>
Your Sex :
<br>
<input type = "radio" value ="man" name = "k" onClick = a(this.value)> MAN <br>
<input type = "radio" value ="woman" name = "k" onClick = a(this.value)> WOMAN <br>
<input type = "text" id = "c">
</body>
</html>


Example 4:

<html>
<head>We Are Knowledge<br>
<title>Tutorial Javascript - Array</title>
<script>
function a()
{
var
b = document.getElementById("b")
document.getElementById("c").value = b.options[b.selectedIndex].text
}
</script>
</head>
<body>
<form>
<select id = "b" onChange = "a()">
<option> Google Chrome</option>
<option> Mozzila Fire</option>
<option> Internet Explorer</option>
<option> Opera Mini</option>
<option> DMOZ</option>
</select>
<p> Your favorit browser is : <input type = "text" id = "c" size = "15"> </p>
</form>
</body>
</html>


Ok... just it...
I hope you understand with this all..
If you not underatand, please leave a comment..

Thanks For you.. Dont forget return...

No comments:

Post a Comment