Reply
Information isn't passing on. Help!
Old 06-03-2006, 11:28 PM Information isn't passing on. Help!
Webmaster Talker

Posts: 554
I'm trying to limit the amount of checkboxes that someone can choose. I want to be able to compare 2 mortgage payment frequencies. Any two can be chosen of Monthly, Bi-Weekly and Weekly. For some reason I am getting an error.

Can someone please help me?

Here is what I have:

index.htm:
Code:
<script type="text/javascript" language="javascript" src="mortgraph.js"></script>

...


	<form>
		Compounding:  
		<select name="comp">
			<option value="2" selected>Semi-annual</option>
			<option value="12">Monthly</option>
		</select><br><br>
		Mortgage Amount: <input type="text" name="amt"><br><br>
		Interest Rate: <input type="text" name="i"><br><br>
		Amortization (years): <input type="text" name="am"><br><br>
		Select to compare (max. 2): 
		<input type="checkbox" name="monthly" checked onclick="alert();"> &nbsp;Monthly&nbsp;&nbsp;&nbsp;
		<input type="checkbox" name="biweekly" checked onclick="max2();"> &nbsp;Bi-Weekly&nbsp;&nbsp;&nbsp;
		<input type="checkbox" name="weekly" onclick="max2()"> &nbsp;Weekly
	</form>
mortgraph.js:
Code:
function max2() {
	var numchecked = 0;
	
	var typ = document.getElementByName('weekly');
	alert(typ);
	if(numchecked > 2) { 
		alert("I'm sorry, you can only view one or two frquencies at a time.");
		return false;
	} else {
		return true;
	}
}
zincoxide is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 06-04-2006, 12:29 AM Re: Information isn't passing on. Help!
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
Wireless Audio
Posts: 2,320
Name: Keith Marshall
Location: West Hartford, CT
HTML:
HTML Code:
 <form>
  Compounding:  
  <select name="comp">
   <option value="2" selected>Semi-annual</option>
   <option value="12">Monthly</option>
  </select><br><br>
  Mortgage Amount: <input type="text" name="amt"><br><br>
  Interest Rate: <input type="text" name="i"><br><br>
  Amortization (years): <input type="text" name="am"><br><br>
  Select to compare (max. 2): 
  <input type="checkbox" name="compare_1" value="monthly" checked onclick="boxchk(this,2);"> &nbsp;Monthly&nbsp;&nbsp;&nbsp;
  <input type="checkbox" name="compare_2" value="biweekly" checked onclick="boxchk(this,2);"> &nbsp;Bi-Weekly&nbsp;&nbsp;&nbsp;
  <input type="checkbox" name="compare_3" value="weekly" onclick="boxchk(this,2)"> &nbsp;Weekly
 </form>
javascript:
Code:
function boxchk(obj,max) {
  var box = obj.name.substr(0,obj.name.lastIndexOf('_')+1);
  var cnt=0,i=1;
  while(obj.form[box+i]) {
    cnt += obj.form[box+i].checked;i++;
  }
  if (cnt > max) {obj.checked = false;
    alert('Only choose ' + max + ' '+ box.substr(0,box.length-1) +' checkboxes.\nTo pick this option unselect one of the others.');
  }
}
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 06-04-2006, 09:10 AM Re: Information isn't passing on. Help!
Webmaster Talker

Posts: 554
thanks mgraphic...

It seems as though you keep bailing me out.
zincoxide is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Information isn't passing on. Help!
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12884 seconds with 12 queries