/    Sign up×
Community /Pin to ProfileBookmark

Changing text area limit

I’m using [URL=”http://www.ccgulfbreeze.com/global/scripts/limit.js”]this code[/URL] to limit the amount of characters allowed in a certain text box. And this is the javascript that you place in the actual page underneath the text area box to make it work, 1000 being the number of charcters to limit it to…

[CODE]displaylimit(“document.webForm.contentBox”,””,1000);[/CODE]

Im using the text area box in a CMS and in this CMS I have a select box that allows you to choose which topic you want to update, I want it so if the user selects Topic 1 or 2 the character limit will be 1000, but if the user selects Topic 3 the character limit will be 210. How can I do this?

to post a comment
JavaScript

12 Comments(s)

Copy linkTweet thisAlerts:
@Angry_Black_ManAug 13.2007 — instead of hardcoding 1000, create a variable that represents the number of characters they can use.

when they select the 3rd topic, set that variable to 210 instead of its default of 1000
Copy linkTweet thisAlerts:
@novemberGreyauthorAug 13.2007 — I tried that but I couldn't ever get it to work, I had something that looked like this...

[CODE]if(document.webForm.id[3].selected){
var limit = "210";
}else{
var limit = "1000";
}

}[/CODE]


But it would only work if you selected the topic than hit the fresh button...
Copy linkTweet thisAlerts:
@Angry_Black_ManAug 13.2007 — would need the complete source to see why it isnt working as expected. and after that it would be advantageous if you pointed out where the 1000 is specifically set against the text area, and perhaps a fix could be worked from there.
Copy linkTweet thisAlerts:
@TJ111Aug 13.2007 — Try something like this:

[code=php]
<script type="txt/javascript">
function getSize(selected) {
var size = "1000";

if (selected == "3") {
size = "210";
}

displaylimit("document.webForm.contentBox", size);
}
</script>
<select name="name" onchange="getSize(document.webForm.id.options[document.webForm.id.selectedIndex].value)">
<option value="1">1</option>
<option value="2">2</option>
<option value="2">3</option>
</select>
[/code]
Copy linkTweet thisAlerts:
@novemberGreyauthorAug 13.2007 — TJ111 I tried your coding and it still wouldn't work...I don't understand what the problem is.
Copy linkTweet thisAlerts:
@LeeUAug 14.2007 — Just change the one in red below. He has it as another 2 and it should be 3:
[CODE]
<select name="name" onchange="getSize(document.webForm.id.options[document.webForm.id.selectedIndex].value)">
<option value="1">1</option>
<option value="2">2</option>
<option value=[COLOR="Red"]"3"[/COLOR]>3</option>
</select>[/CODE]
Copy linkTweet thisAlerts:
@novemberGreyauthorAug 14.2007 — What do you mean? What do I change it to?
Copy linkTweet thisAlerts:
@TJ111Aug 15.2007 — Change it to 3. I accidentally set the values as 1,2,2 when they should be 1,2,3.
Copy linkTweet thisAlerts:
@novemberGreyauthorAug 15.2007 — Ok thanks... I did that that but it still doesn't work...
Copy linkTweet thisAlerts:
@novemberGreyauthorAug 15.2007 — it's like if the limit isn't hard coded the limit string just disappears totally...
Copy linkTweet thisAlerts:
@p_phreshAug 15.2007 — post your corresponding code.
×

Success!

Help @novemberGrey spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...