Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can radio buttons be written with javascript?

Status
Not open for further replies.

antonb

Technical User
Nov 16, 2000
7
CA
For an online survey, ordinarily one uses radio buttons
under the scale interval definitions, like this,

SD D N A SA
x x x x x

where the "x"s are the radio buttons.


I would like to script radio functionality on the scale
letters themselves, so that the survey page has a flatter,
cleaner appearance, i.e.,

SD D N A SA

where clicking on the scale letter swaps in a darker
letter image for that letter, and only one of five scale
intervals can be selected per set (radio-like).

Is this possible in javascript? I found a radio object
written by Dan Steinman at the DynamicDuo page


but am having trouble figuring out how to adapt it
to this notion above.

The questionnaire has 76 items (will have 76 radio
objects on the form).

Can anyone suggest a way to do this efficiently? I
checked all the forums and FAQs I could find searching
for "radio" and have seen nothing at all about this
except at Steinman's page.


This is Dan Steinman's radio object script below.
An example of its use is at the URL above.


Code:
 // Radio Object
 // allows you to use images to replace HTML Radio Buttons
 // 19990326

 // Copyright (C) 1999 Dan Steinman
 // Distributed under the terms of the GNU Library
    General Public License
 // Available at [URL unfurl="true"]http://www.dansteinman.com/dynduo/[/URL]



function Radio(layer,imgNames,length,defaultValue) {
	this.layer = layer
	this.imgNames = imgNames
	this.length = length
	this.change = RadioChange
	this.value = (defaultValue)? defaultValue : "undefined"
}

function RadioChange(index,value) {
	this.value = value
	for (var i=0; i<this.length; i++) changeImage(this.layer,this.imgNames+i,'radio0')
	changeImage(this.layer,this.imgNames+index,'radio1')
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top