Click to See Complete Forum and Search --> : Switch form by radio button


Ipsens
October 29th, 2006, 12:31 PM
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

PeejAvery
October 29th, 2006, 03:15 PM
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.

Ipsens
October 29th, 2006, 04:01 PM
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?

PeejAvery
October 29th, 2006, 04:38 PM
You understand now?
I understood before. Read the first part of my post and that is your answer.

Ipsens
October 29th, 2006, 05:04 PM
Ok,

now give me a JS code, please.

PeejAvery
October 29th, 2006, 06:37 PM
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]

Ipsens
October 30th, 2006, 05:14 AM
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?

PeejAvery
October 30th, 2006, 09:49 AM
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.

Ipsens
October 30th, 2006, 10:01 AM
Yes I use FF.

Will do that...