Go Back   DevHunters.com l Webmaster Forum - Web Advertising - Web Design - SEO Forums > Webmaster / Coding / Web Design Discussion > JavaScript Programming

JavaScript Programming Discuss javascript coding.

Have A Look At Some Of Our Webmaster Related Sponsors!


Script Directory


Advertise Here


Market Leverage


Free Templates

3D Guide-Characters
3D Guide-characters


Advertise Here

Reply
 
LinkBack Thread Tools Display Modes
Old 06-12-2008, 04:00 AM   #1 (permalink)
New Hunter
 

Join Date: Jun 2008
Posts: 2
iTrader: 0 / 0%
Hunter Bux: 0
hazrizal84 is on a distinguished road
Default select() statement..help me plzz..

hi..anyone can help me solve this prob...actually when these codes run in IE, there is no prob at all..but not with mozilla firefox..plz help me...

[highlight="JavaScript"]<html>
<head>
<script type="text/javascript">
window.onload=function()
{
var inps=document.getElementsByTagName('input');
for(var i=0;i<inps.length-1;i++)
{
inps[i].onblur=function()
{
if(this.value.indexOf('/')!=-1&&(this.value.length>1))
{
alert('Answers should either be number or slash only!\nNo Combination Please.');
this.select();
}
}
}
}
</script>

</head>
<body>
<p>Please enter your answer or type ( / ) if you don't know the answer.<br>
Your answer may not contain both numbers and ( / ) sign.<br><br>
34 + 54 = <input type=text size="6"></p>
<p>123 + 76 = <input type=text size="6" name="T1"></p>
<input type=submit value="Check Answer!">
</body>
</html>[/highlight]

Last edited by SpOrTsDuDe.Reese; 06-12-2008 at 10:27 AM. Reason: Added [highlight] tags
hazrizal84 is offline   Reply With Quote
Old 06-12-2008, 10:26 AM   #2 (permalink)
Senior Moderator
 
SpOrTsDuDe.Reese's Avatar
Default

Try

Code:
<html> 
<head> 
<script type="text/javascript"> 
function nice() { 
	var inps=document.getElementsById('box'); 
	for(var i=0;i<inps.length-1;i++) 
		{ 
			inps[i].onblur=nice();
		{
				if(inps.value.indexOf('/')!=-1 && (inps.value.length>1)) 
					{ 
						alert('Answers should either be number or slash only!nNo Combination Please.'); 
inps.select();
				} 
			} 
		} 
	} 
</script> 

</head> 
<body onLoad="cool();"> 
<p>Please enter your answer or type ( / ) if you don't know the answer.<br> 
Your answer may not contain both numbers and ( / ) sign.<br><br> 
34 + 54 = <input type=text size="6"></p> 
<p>123 + 76 = <input type=text size="6" name="T1" id="box></p> 
<input type=submit value="Check Answer!"> 
</body> 
</html>
Your code seems to be a bit quirky. Like this line for example something looks wrong.

inps[i].onblur=nice();
__________________
+-(X)HTML, CSS, JavaScript, SEO, PHP, Flash-+
Code:
<style type="text/css"> u { text-decoration: none; } </style>
GameYin. Redesigning for DevPlooth.
SpOrTsDuDe.Reese is offline   Reply With Quote
Old 06-13-2008, 10:19 PM   #3 (permalink)
New Hunter
 

Join Date: Jun 2008
Posts: 2
iTrader: 0 / 0%
Hunter Bux: 0
hazrizal84 is on a distinguished road
Default

sir, have u tried the codes u gave me?..it cannot be run at all! my codes are better...
hazrizal84 is offline   Reply With Quote
Old 06-14-2008, 10:58 AM   #4 (permalink)
Senior Moderator
 
SpOrTsDuDe.Reese's Avatar
Default

No I didn't run it. Though I'd go to forums.devshed.com and post there. They have some real geniuses there.
__________________
+-(X)HTML, CSS, JavaScript, SEO, PHP, Flash-+
Code:
<style type="text/css"> u { text-decoration: none; } </style>
GameYin. Redesigning for DevPlooth.
SpOrTsDuDe.Reese is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -5. The time now is 11:25 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios