Ask a Question related to Macromedia Dynamic HTML, Design and Development.
-
Dan-CFTagStore.com #1
Re:Scripting Question -- Limiting Form Input
Hi,
See attached code.
This will do the trick and hopefully is what your looking for.
Regards,
Dan.
<script>
function checkValue(theId) {
var numberOfElements=document.getElementById("myForm") .elements.length;
var theValueToCheck=document.getElementById(theId).val ue;
if(theValueToCheck>=0 && theValueToCheck <=10) {
for(i=0;i<numberOfElements;i++) {
if(document.getElementById("myForm").elements[i].value==theValueToCheck && document.getElementById("myForm").elements[i].id!=theId) {
alert("Value already used");
document.getElementById(theId).value="";
document.getElementById(theId).focus();
break;
}
}
} else {
alert("Rating is only between 1 and 10");
document.getElementById(theId).value="";
document.getElementById(theId).focus();
}
}
</script>
<form name="myForm" id="myForm">
<table>
<tr>
<td>Option 1</td>
<td><input type="text" onblur="checkValue(this.id)" size=2 name="order1" id="order1"></td>
</tr>
<tr>
<td>Option 2</td>
<td><input type="text" onblur="checkValue(this.id)" size=2 name="order2" id="order2"></td>
</tr>
<tr>
<td>Option 3</td>
<td><input type="text" onblur="checkValue(this.id)" size=2 name="order3" id="order3"></td>
</tr>
<tr>
<td>Option 4</td>
<td><input type="text" onblur="checkValue(this.id)" size=2 name="order4" id="order4"></td>
</tr>
<tr>
<td>Option 5</td>
<td><input type="text" onblur="checkValue(this.id)" size=2 name="order5" id="order5"></td>
</tr>
<tr>
<td>Option 6</td>
<td><input type="text" onblur="checkValue(this.id)" size=2 name="order6" id="order6"></td>
</tr>
<tr>
<td>Option 7</td>
<td><input type="text" onblur="checkValue(this.id)" size=2 name="order7" id="order7"></td>
</tr>
<tr>
<td>Option 8</td>
<td><input type="text" onblur="checkValue(this.id)" size=2 name="order8" id="order8"></td>
</tr>
<tr>
<td>Option 9</td>
<td><input type="text" onblur="checkValue(this.id)" size=2 name="order9" id="order9"></td>
</tr>
<tr>
<td>Option 10</td>
<td><input type="text" onblur="checkValue(this.id)" size=2 name="order10" id="order10"></td>
</tr>
</table>
</form>
Check Out : [url]www.cftagstore.com[/url] for the latest and greatest Coldfusion custom tags and components!
Built by developers, for developers!
Dan-CFTagStore.com Guest
-
Question on limiting choices in WebPart personalization
Just use an enum for the property. -- Riki "Ron Ruble" <RonRuble@discussions.microsoft.com> wrote in message... -
Perl Newbie question: How would you take keyboard input and run a shell scrip with that input?
I don't think you could be vaguer :) Very basic #!/usr/bin/perl # update.pl multiple options command line my @packages = @ARGV foreach... -
limiting character input into editable fields
Is there any way to limit the types of characters that a user can type into an editable field? For example can the field be limited to only... -
#25676 [Opn->Bgs]: Form hidden input ouput when any form=* is in url_rewriter.tags
ID: 25676 Updated by: sniper@php.net Reported By: davey@php.net -Status: Open +Status: Bogus Bug... -
#25676 [Opn]: Form hidden input ouput when any form=* is in url_rewriter.tags
ID: 25676 Updated by: davey@php.net Reported By: davey@php.net Status: Open Bug Type: Session related...



Reply With Quote

