SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jquery mutiple fields

    what i use to make a form like this that user can add automatic multiple input fields how much they want then i can get the data of all
    here is demo
    www.ukash2paypal.com/

    m also notice one more thing in source that form action is going in cgi-bin folder
    is there any already created code relative to this :S or any can help to make like this that

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by realcoder View Post
    what i use to make a form like this that user can add automatic multiple input fields how much they want then i can get the data of allp
    Here's a suitable tutorial:
    jQuery - Dynamically Adding Form Elements

    Quote Originally Posted by realcoder View Post
    m also notice one more thing in source that form action is going in cgi-bin folder
    The cgi-bin folder is for server-side scripting, similar to PHP code. cgi-bin is an ancient form of it that commonly uses PERL as the scripting language.

    These days, you will want to use PHP or ASP or some other more relevant server-side scripting solution.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how i get values which condition i apply on loop
    that i don't need to mention these separelty autmatic how much input field user increase my loop also increas and change value in $_POST['name']-->[change this value auto]
    instead of i have to write it separetly like this

    $one = $_POST['name'][0];
    $two = $_POST['name'][1];
    $thre = $_POST['name'][2];
    $for = $_POST['name'][3];

  4. #4
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well don't know much about jquery
    but everything is going good i can get values of each input using
    $one = $_POST['name'][0];
    $two = $_POST['name'][1];
    $thre = $_POST['name'][2];
    $for = $_POST['name'][3];

    but just want to know if i use for loop
    like this
    for ($i=1; $i<=5; $i++){
    $_POST['name'][$1]
    }
    which condition i use $1<= instead of 5 because i don't know the exact inputs which user give ???

  5. #5
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by realcoder View Post
    how i get values which condition i apply on loop
    that i don't need to mention these separelty autmatic how much input field user increase my loop also increas and change value
    Using the tutorial as an example:

    You can use the array_keys function and loop through them all checking that the key matches what you're after

    Code php:
    $name = array();
    foreach($_POST as $key => $value) {
        if (substr($key, 0, 4) === 'name') {
            $name[] = $value;
        }
    }

    or you can use a while loop that carries on getting the next appropriate form value while one still exists.

    Code php:
    $name = array();
    $index = 0;
    while (isset($_POST['name'] . $index)) {
        $name[] = $_POST['name' . $index];
    }

    You're lucky getting this type of code here, as this is the JavaScript forum.
    Please post a new thread to the PHP forum for further PHP code support.
    Last edited by paul_wilkins; Nov 25, 2010 at 06:36.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  6. #6
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why ur second one php code give errror

  7. #7
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by realcoder View Post
    why ur second one php code give errror
    I shouldn't be replying now, it's 1:30am, but possibly because there's a missing bracket. No, it's because this is the JavaScript forum and I've been using JavaScript concatenators when instead PHP concatenators should be used. The code is updated now.

    I knew I shouldn't have posted PHP code in the JavaScript forum.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

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