Switch form by radio button
Hi!
Now I have a little more advance form and simply beacuse I wana save space I need to use Java script.
This is a form.
In a middle of it I wana to put a row(colspan=2).
This row will have 2 radio butons.
Below are 2 rows each having 2 <TD>s
Here Java script kicks in.
One radiobutton is active by default, but if the other is clicked,
than 2 rows below shift.
Left radio button = Enter VISA cc
Right radio button = Enter MASTER cc
It affects left sides(<TD>) of a 2 rows below, shifting text of a fields.
ie: "Your VISA cc" then "Your MASTER cc"
Thanks in advance!
Ipsens
[677 byte] By [
Ipsens] at [2007-11-20 2:30:40]

# 1 Re: Switch form by radio button
You can just use a DIV and alter its innerHTML.
But, if you are working with information change, you should do the calculating of the changes on the server-side.
# 2 Re: Switch form by radio button
No no, I know that for a server side.
I'm talking about a form that is about to be sent to PHP in a form.
So..., take it simpler.
When I click one of radio buttons one layer is shown, but when I click other radio button then first layer dissapear and second is shown and vice versa.
You understand now?
# 5 Re: Switch form by radio button
Example:
[code]<script language="JavaScript">
function changeCard(which){
var theDiv = document.getElementById('divCard');
if(which == "Mastercard"){
theDiv.innerHTML = "Mastercard";
}
if(which == "Visa"){
theDiv.innerHTML = "Visa";
}
}
</script>
<div id="divCard"></div>[code]
# 6 Re: Switch form by radio button
Thank you,
But one of 2 buttons have checked value and it doesn't show ANY value until I click one.
One must alraedy be active like it was clicked on.
What is a code for that?
Also why if I try to put a code of complex table in
theDiv.innerHTML =
instead of simple "VISA" or "MASTERCARD" string, nothing shows up on a screen?
# 7 Re: Switch form by radio button
So use the document.onload function to start the function.
Do you have Firefox? When scripting, Firefox is a programmers best tool because it has an Error Console which displays all errors.