Hello everyone.
i am fairly new to javascript and having problems attaching an event listener to a radio button .
i am trying to get the values from a clicked radio button so that i can then attach those values to a javascript enclode64. but i don't seem to be able to attach to the event.
it might be easier if i show u what i have done so far;
The HTML radio button tag: They are NOT enclosed within a form
the javacript codePHP Code:<input class="link-selector-flash" type="radio" name="link-type" id="link-type-template" data-url-base="www.sample.url1" />
<input class="link-selector-flash" type="radio" name="link-type" id="link-type-template" data-url-base="www.sample.url2" />
<input class="link-selector-flash" type="radio" name="link-type" id="link-type-bespoke" data-url-base="www.sample.url2" />
you will note that i tried to place the returned value in a Base64 encode ( i have not enclosed the javacript code for the encoder as this has been separately tested and it works perfectly.PHP Code:window.onload = function(){
document.getElementsByName('link-type').onclick = function(){
alert('it works link name');
var radioButtons = document.getElementsByName("link-type");
for (var i = 0; i < radioButtons.length; i++) {
if (radioButtons[i].checked) {
var thevalue = radioButtons[i].value;
document.getElementById('str64').value = Base64.encode(thevalue);
}
}
}
the imput bar that i tried to transfer it to is listed below .
The code fell apart because i don't seem to be able to attach the right event to the listener. i.e to listen for the click of the radio button.PHP Code:<input type="text" name="str64" id="str64" size="34" />
warm regards
Andreea



Reply With Quote


Bookmarks