[thelist] AJAX - expose a div with radio buttons, select & submit/save to mysql

Simon MacDonald simonmacdonald at uk2.net
Fri Aug 13 03:11:23 CDT 2010


Bob 

If I understand correctly what you are trying to do you could try this. 
I have used the mootools $$ function to return an  array of input tags of a
particular class and then walk the array to find the checked one - you would
have to add a different class to each input set and walk each one. 
There's probably neater ways of coding it but it worked for me.
(apologies in advance for any typos - I always manage to get some in!)

=============html=========================================

<div class="stretcher">
<p class="compact">

<input class-"q7" name="Q7" value="0" type="radio"><span>0</span> 
<input class-"q7" name="Q7" value="1" type="radio"><span>1</span> 
<input class-"q7" name="Q7" value="2" type="radio"><span>2</span> 
<input class-"q7" name="Q7" value="3" checked="checked"
type="radio"><span>3</span> 
<input class-"q7" name="Q7" value="4" type="radio"><span>4</span> 
Element 1  
</p>
<p class='c'><input type="submit" name="submit" value="Save &raquo;"
onClick="getCloseRating()></p>
.
.

=============Javascript=========================================

function getCloseRating(){

// get checked button
	var pt = $$("input.q7");// mootools $$ function returns an array of
input tags with class q7
	// walk the array to find checked button
	if (pt.length != 0)// check to see if a button selected
	{
		var ptIndex = "";
		for (var i=0; i < pt.length; i++)
	   {
		   if (pt[i].checked)
			  {
				//do something
			  } 
	   }

}


HTH 

Simon
 

__________ Information from ESET Smart Security, version of virus signature
database 5362 (20100813) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 



More information about the thelist mailing list