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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Total Radio Buttons and Display Msgbox or text in a frame

Status
Not open for further replies.

jadams

IS-IT--Management
Jul 21, 2000
3
0
0
US
I want to develop a form that looks like this:<br>Q1 ....? ()yes ()no<br>Q2 ....? ()yes ()no<br>Q3.....? ()yes ()no<br>etc........<br>Q10....? ()yes ()no<br><br>I want the script to total up the &quot;Yes&quot; and then if:<br>If total &lt;3 then popupwindow total &gt;3&lt;=6 then popupwindow total 7&gt; then popupwindows really don't need a new window to open, I could put the info in a frame, or in an iframe, or a cell of a table.<br>I'm a new js programmer but I know enough to know that I will need:<br><br>1. A function in the head<br>2. The ability for the user to check more than one button.<br>3. An &quot;on submit&quot; event which will run the function.<br>Any help would be greatly appreciated and I would be more than happy to credit the folks who help me do this on my non-profit company's web sit.<br><br>Jim Adams<br>
 
Please provide me a link to the page you use this on:<br><br>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;&gt;<br><br>&lt;html&gt;<br>&lt;head&gt;<br> &lt;title&gt;Untitled&lt;/title&gt;<br>&lt;/head&gt;<br><br>&lt;script&gt;<br>var totalyes //global variable to store total yesses<br><br>function checkRadios()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;var yeschex=0;var nochex=0<br>&nbsp;&nbsp;&nbsp;&nbsp;var frm = document.darg.elements&nbsp;&nbsp;//all the checkboxes<br>&nbsp;&nbsp;&nbsp;&nbsp;var len = frm.length&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//how many there are<br>&nbsp;&nbsp;&nbsp;&nbsp;for(var i=0;i&lt;len;i++)<br>&nbsp;&nbsp;&nbsp;&nbsp;{if(frm<i>.checked){if(frm<i>.value=&quot;y&quot;){yeschex++}}}<br>&nbsp;&nbsp;&nbsp;&nbsp;return yeschex<br>}<br><br>function testTotal(howmany)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;if(howmany &lt; 3){mypop = window.open(&quot;page1.htm&quot;,&quot;winny&quot;,&quot;width=300,height=400&quot;)}<br>&nbsp;&nbsp;&nbsp;&nbsp;if(howmany &gt; 3 && &lt;=6){mypop = window.open(&quot;page2.htm&quot;,&quot;winny&quot;,&quot;width=300,height=400&quot;)}<br>&nbsp;&nbsp;&nbsp;&nbsp;if(howmany &gt;= 7){mypop = window.open(&quot;page3.htm&quot;,&quot;winny&quot;,&quot;width=300,height=400&quot;)}<br>}<br><br>&lt;/script&gt;<br><br>&lt;body&gt;<br>&lt;form name=&quot;darg&quot;&gt;<br>Do you Like...&lt;br&gt;&lt;br&gt;<br>Root Beer?&lt;input type=&quot;radio&quot; name=&quot;rootbeer&quot; value=&quot;y&quot;&gt;Yes<br>&lt;input type=&quot;radio&quot; name=&quot;rootbeer&quot; value=&quot;n&quot;&gt;No&lt;br&gt;<br>Flying?&lt;input type=&quot;radio&quot; name=&quot;flying&quot; value=&quot;y&quot;&gt;Yes<br>&lt;input type=&quot;radio&quot; name=&quot;flying&quot; value=&quot;n&quot;&gt;No&lt;br&gt;<br>Aliens?&lt;input type=&quot;radio&quot; name=&quot;aliens&quot; value=&quot;y&quot;&gt;Yes<br>&lt;input type=&quot;radio&quot; name=&quot;aliens&quot; value=&quot;n&quot;&gt;No<br>&lt;/form&gt;<br>&lt;form&gt;&lt;input type=&quot;button&quot; onClick=&quot;totalyes = checkRadios();testTotal(totalyes)&quot;&gt;&lt;/form&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;
 
I keep getting a syntax error in line 23 and I can't see why.<br>Thanks JA
 
oops... heres the fix:<br><br>function testTotal(howmany)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;if(howmany &lt; 3){mypop = window.open(&quot;page1.htm&quot;,&quot;winny&quot;,&quot;width=300,height=400&quot;)}<br>&nbsp;&nbsp;&nbsp;&nbsp;if(howmany &gt; 3 && <font color=red>howmany</font> &lt;=6){mypop = window.open(&quot;page2.htm&quot;,&quot;winny&quot;,&quot;width=300,height=400&quot;);}<br>&nbsp;&nbsp;&nbsp;&nbsp;if(howmany &gt;= 7){mypop = window.open(&quot;page3.htm&quot;,&quot;winny&quot;,&quot;width=300,height=400&quot;)}<br>}<br><br>forgot the second howmany (in red above).<br><br>hope ive helped<br><A HREF="mailto:jared@aauser.com">jared@aauser.com</A>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top