Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Information isn't passing on. Help!
Old 06-04-2006, 12:28 AM Information isn't passing on. Help!
Webmaster Talker

Posts: 626
Trades: 0
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;
	}
}
jim.thornton is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-04-2006, 01:29 AM Re: Information isn't passing on. Help!
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
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, 10:10 AM Re: Information isn't passing on. Help!
Webmaster Talker

Posts: 626
Trades: 0
thanks mgraphic...

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.48844 seconds with 12 queries