PDA

View Full Version : How to post text after selecting radio button


yasoumalaka
08-18-2005, 08:43 PM
I'm a small pc builder and I'm building a site that uses radio button groups in a form to allow people to custom configure there system. I would like to be able to show how much more it would be for particular upgrades but I want it to change in relation to whats currently selected. This is common on most pc builder sites. How would I do this or can anybody offer me a suggestion on where to look to learn this sort of thing.

davidj
09-14-2005, 03:49 PM
///// insert in the head tags ///////
//////////////////////////////////////

<script language="JavaScript" type="text/javascript">
function newtext1(){
document.getElementById("newtxt").innerHTML = 'this now costs 40000';
}
function newtext2(){
document.getElementById("newtxt").innerHTML = 'this now costs 44.00';
}
function newtext3(){
document.getElementById("newtxt").innerHTML = 'this now costs 666.00';
}

</script>
////////////////////////////////////////////
///////insert in the body tags //////////

<input type="button" name="Button" value="Button" onclick="newtext1()">
<input name="radiobutton" type="radio" value="1" onclick="newtext2()">
<input name="radiobutton" type="radio" value="2" onclick="newtext3()">

davidj
09-15-2005, 10:01 AM
sorry

i forgot to add a div

add this where you want the new text to display

<div id="newtxt"></div>

davidj
09-15-2005, 10:53 AM
as im sure some one will simplify those functions into 1



function newtext1(v){

switch (v){

case '1':
document.getElementById("newtxt").innerHTML = 'this now costs 40000';
break;

case '2':
document.getElementById("newtxt").innerHTML = 'this now costs 356;
break;

case '3':
document.getElementById("newtxt").innerHTML = 'this now costs 22;
break;

}

}
///////////////////


<input type="button" name="Button" value="Button" onclick="newtext1('1')">
<input name="radiobutton" type="radio" value="1" onclick="newtext1('2')">
<input name="radiobutton" type="radio" value="2" onclick="newtext1('3')">

//////////////////

<div id="newtxt"></div>