Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2010
    Location
    Slovenia
    Posts
    39
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Run a string through PHP

    Hi!

    I have a form, to create a new page in PHP. So, when I enter page title, and send the form over, the title will be processed into a shorter string, without special characters and spaces. What I want is, the title to be processed immediately, and displayed under the input.
    Help please?

    Thanks.

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Quote Originally Posted by ItsGreg View Post
    Hi!

    I have a form, to create a new page in PHP. So, when I enter page title, and send the form over, the title will be processed into a shorter string, without special characters and spaces. What I want is, the title to be processed immediately, and displayed under the input.
    Help please?

    Thanks.
    Option 1:
    Use AJAX to post your text input to a PHP page that simply echos the processed version of whatever it receives. Drop that AJAX response into a holding element underneath your form input field.
    Pros: actual PHP-processed content
    Cons: delayed response

    Option 2:
    Create javascript versions of the PHP functions you'll be using, and run your input values through that.
    Pros: instant response
    Cons: possible variation between JS and PHP implementation

  • #3
    Regular Coder
    Join Date
    Jul 2006
    Posts
    399
    Thanks
    33
    Thanked 7 Times in 7 Posts
    It depends if youre keeping your data in a database or not, to just show a title wich was inserted by a user thru a input text field does not require Ajax if no Database is in between.

    Check this:
    http://daniel.lorch.cc/docs/ajax_simple/

    It will help you to understand the basics.
    Last edited by sybil6; 11-04-2010 at 02:02 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •