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

Bob Meetin bobm at dottedi.biz
Fri Aug 13 21:31:39 CDT 2010


Simon, all,

Thanks, but I don't really understand how to put this together.  To make 
this a little easier to troubleshoot I made up a working (failing) demo 
which saves toplevel ratings.  See it and all files at: 
http://www.dottedi.biz/code/ajax/rating/index.php, including a zip file 
to test locally.

-Bob

Simon MacDonald wrote:
> For class-"q7" read class="q7" - told you I was good at typos
> S
>
> 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
>   



More information about the thelist mailing list