-twenty Posted November 30, 2009 Share Posted November 30, 2009 I know this is done with JS, I just can't find any examples on how it's done. I'm looking for a form to automatically post once the character count in a textbox reaches a certain number. Can anyone suggest any examples? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 30, 2009 Share Posted November 30, 2009 when checking the form for the character you can use the javascript submit() function to post the form Quote Link to comment Share on other sites More sharing options...
-twenty Posted November 30, 2009 Author Share Posted November 30, 2009 Cool, thanks for the quick response! But I'm not quite sure that's what I'm looking to do... When character count = 10, then submit the form. Quote Link to comment Share on other sites More sharing options...
Iainzor Posted November 30, 2009 Share Posted November 30, 2009 First, it depends on how you want to do it, the easy way (JS framework) or hard way (built-in javascript functions). I don't know if you have experience with JS, but you need to make javascript send a POST or GET request to a page with the content using the format "/url?post=[...]" which you would process like any other form using PHP. From briefly searching google for "PHP AJAX tutoria"l, I found this. It covers sending the request without using a framework. If you're going to use a framework I suggest either MooTools or jQuery. I prefer Mootools mostly because it's geared more toward programmers and I find the native extensions very useful. Edit: To post when the character count is a set amount, you simple do this (using Mootools): var ta = $('myTextarea'); ta.addEvent('keyup', function() { var length = ta.get('value').length; if(length >= 10) { var value = length.substr(0, 10); // Send POST request } } Quote Link to comment Share on other sites More sharing options...
-twenty Posted November 30, 2009 Author Share Posted November 30, 2009 Realistically I'd like to do it without a framework since this will be the only piece of JS in the application, so traditional javascript functions are preferred...this is seeming to be a harder task then I thought it would have been! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.