cancel
Showing results for 
Search instead for 
Did you mean: 

Change Button content when Radio button clicked...

Former Member
0 Kudos

Within my BSP code I have an OnClientClick event against the Radio button tag.

What I need to do is to have some kind of Javascript that changes the context (text) or colour of a button if the Radio button is clicked.

I know very little of how to achieve this and would relish any guidance about how I can get this to work.

I understand that I need to use a reference/handle to the button and change it's values via javascript, but how can I embed this code into my BSP code, what code do I use, and more importantly how can I obtain this reference/handle on the buttion?.

Jon

Accepted Solutions (0)

Answers (1)

Answers (1)

athavanraja
Active Contributor
0 Kudos

check

htmlb_samples/radiobuttongroupSample.htm

also familiarize yourself with javascript .

i used

http://www.w3schools.com/js/default.asp

Edited by: Durairaj Athavan Raja on Apr 23, 2011 8:43 AM

Former Member
0 Kudos

Your url of htmlb_samples/radiobuttongroupSample.htm

points to OpenDNS but does not display any content as such. Is this the correct URL do you know.

With regards

Jon

alespad
Contributor
0 Kudos

Hi Jon,

below an Example to do this

(due to security forum restriction replace scrip t with script and o nclick with onclick)

<html>
<head>
<scrip t>
function change_button_text(v_object){

var button = document.getElementById("id_button");

var new_text = v_object.value + ' Clicked!';
if (button.childNodes[0])
      {
        button.childNodes[0].nodeValue=new_text;
      }
    else if (button.value)
      {
        button.value=new_text;
      }
}
</scrip t>

</head>

<body>
<form>
<input type="radio" name="sex" value="male" o nclick="change_button_text(this)"/> Male<br />
<input type="radio" name="sex" value="female" o nclick="change_button_text(this)"/> Female
</form>
<button id="id_button">Button Text</button>
</body>
</html>

Edited by: alessandro spadoni on Apr 28, 2011 9:56 AM

Former Member
0 Kudos

Alessandro,

That's very much appreciated. I had to change this slightly as we are using our own tags to display buttons, but I got it to work all the same.

Regards

John Sapora