[trick] Pergantian Form Onchange Javascript

Code Html

<title>Pergantian Form Onchange</title>
function ganti(){
var a = document.getElementById("pilihan").value;
if(a == ""){
document.getElementById("status").innerHTML="Pilih Dulu Ya";
var ajak =new XMLHttpRequest();
var url = "combo.php";
var nilai = "variable="+a;
ajak.onreadystatechange = function(){
if(ajak.readyState == 4 && ajak.status == 200){
var return_data = ajak.responseText;
document.getElementById("status").innerHTML= return_data;

<form method=POST action="tujuan.php">
Pilih Variable : <select id="pilihan" onchange="ganti()">
<option value="00">Pilih Variable </option>
<option value="01">01</option>
<option value="02">02</option>
<div id="status">
<p>UN : <input type=text name='username'></p>
<p>LN : <input type=text name='lastname'></p>
<input type="submit" value="simpan">

Code Php

echo"<p>UN : <input type=text name='username' value='01'></p>";
echo"<p>LN : <input type=text name='lastname' value='02'></p>";
echo"<p>UN : <input type=text name='username' value='03'></p>";
echo"<p>LN : <input type=text name='lastname' value='04'></p>";

Leave a comment

1 Comment

  1. Reblogged this on Dinesh Ram Kali..


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: