Jump to content

(help)Auto Complete chars in a form


nicx

Recommended Posts

All php master. I want to ask

something about sintax php. My

question: i have a form and it contains

160 character,user usually add less

than 160 . How the sintax php to

auto complete to 160 char with space, if

user add less than 160?? Plz help.

Link to comment
Share on other sites

<?php
// $input contains user input

function add_whitespace($input) {
    $zeros = 160 - str_len($input);
    $buf = "";

    for ($x=1,$x<$zeros;$x++) {
      $buf = $buf . " ";
    }

    return $input . $buf;
}
?>

Link to comment
Share on other sites

Thanks all. But im confused to fusion that. This my form:   

<?php

 

echo "Text:<br />

    <textarea name=\"message\" maxlenght=\"160\"></textarea><br/>"; ?>

 

how to fusion with keeB script?? 

Link to comment
Share on other sites

<?php
// $input contains user input

function add_whitespace($input) {
    $zeros = 160 - str_len($input);
    $buf = "";

    for ($x=1,$x<$zeros;$x++) {
      $buf = $buf . " ";
    }

    return $input . $buf;
}
?>

how with this:

<?php

 

echo "Text:<br />

    <textarea name=\"message\" maxlenght=\"160\"></textarea><br/>";

 

// $input contains user input

 

function add_whitespace($message) {

    $zeros = 160 - str_len($message);

    $buf = "";

 

    for ($x=1,$x<$zeros;$x++) {

      $buf = $buf . " ";

    }

 

    return $message . $buf;

}

 

?>

 

only changes $input to $message ?? Thats true? Plz keeB answer plz hehe

Link to comment
Share on other sites

I was write the keeB scrite to my file,but the warning: Parse error : syntax error,

unexpected ')', expecting ';' in 

/home/nicx/public_html/dir/

form.php  on line  41

 

@keeB,your sintax have some mistake? Plz give the right sintax! Thans

Link to comment
Share on other sites

<?php
// $input contains user input

function add_whitespace($input) {
    $zeros = 160 - str_len($input);
    $buf = "";

    for ($x=1;$x<$zeros;$x++) {
      $buf = $buf . " ";
    }

    return $input . $buf;
}
?>

 

d'oh. Updated.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.