You should never rely on JavaScript working when you use the same ID
on more than one thing in a page; IDs should be treated as unique.
Your browser is picking one of the radio buttons (the first or the
last, most likely) and using that one.
You could loop through the ten radio buttons and build a list to send
to the AJAX call, so instead of
var DSID = document.getElementById("qType").value;
You'd have a for loop. Remeber you can use something like '
document.getElementById("qType_" + i)
to get qType_1, qType_2 etc.
On 7/21/07, Will Tomlinson <[EMAIL PROTECTED]> wrote:
> ok, I'm tryin to implement the same mxAjax coolness with radio buttons
> instead of my select menu. My problem is, getelementbyid() is using the first
> radio button value only.
>
> I have about 10 radio buttons, all with different values. When I select one,
> it needs to feed getelementbyid() with its value, so it can then be sent into
> my ajax cfc.
>
> I'm guessin JS deals with radio buttons differently. The ajax call works
> perfectly - just uses one radio value only. lol.
>
> Did some googlin, no luck.
>
> Here's my ajax call:
>
> <script language="javascript">
> var url =
> "http://localhost:8500/mysite/mxajax/core/cf/example.cfc";
>
> function init() {
> var DSID = document.getElementById("qType").value;
>
> new mxAjax.Data({
> executeOnLoad:true,
> paramArgs: new mxAjax.Param(url,{param:"DSID=" + DSID,
> cffunction:"getDistractors"}),
> postFunction: handleData
> });
>
> function handleData(response) {
> var myHTMLOutput = JSON.parse(response);
> document.getElementById("showDistractors").innerHTML =
> myHTMLOutput;
> }
> }
>
>
> </script>
>
> Here's my form stuff:
>
> <p><input name="qType" id="qType" type="radio" value="1" onclick="init();"
> /> Likert Scale</p>
>
>
> <p><input name="qType" id="qType" type="radio" value="4"
> onclick="init();" /> Yes/No</p>
>
> <p><input name="qType" id="qType" type="radio" value="25"
> onclick="init();" /> Yes/No with Not sure</p>
>
> <p><input name="qType" id="qType" type="radio" value="26"
> onclick="init();" /> Satisfaction Ratings</p>
>
> <p><input name="qType" id="qType" type="radio" value="27"
> onclick="init();" /> Quality Ratings</p>
>
> <p><input name="qType" id="qType" type="radio" value="28"
> onclick="init();" /> Amount Ratings</p>
>
>
> <p><input name="qType" id="qType" type="radio" value="29"
> onclick="init();" /> GPA Ratings</p>
>
> <p><input name="qType" id="qType" type="radio" value="30"
> onclick="init();" /> Grade Ratings</p>
>
> Any ideas anyone? James?
>
> Thanks much,
> Will
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7
The most significant release in over 10 years. Upgrade & see new features.
http://www.adobe.com/products/coldfusion?sdid=RVJR
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:284284
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4