SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    upstate NY, USA
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    moved to server-side forum

    Sorry I was unable to delete this thread
    ****************************************

    Help pleeze...

    I'm not sure how to name and pass form variables created within a loop.

    Here is what I tried:
    while(conditional statement)
    {
    <input type="hidden"
    name="item_num"<?echo$var_x;?
    value=<?echo $var_x;?>>
    }

    where I've given the hidden field a unique name within the loop.

    What would the php (or javascript) reference be for the hidden field or is there a better way to name it?
    Last edited by jtsmk; Sep 6, 2001 at 08:00.

  2. #2
    Victory shall be mine tubedogg's Avatar
    Join Date
    Mar 2001
    Location
    Medina, OH
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Four things I see wrong with that code:

    1. You are using additional PHP open & close tags (albeit invalid ones) inside an already open PHP section. Going along with this, you didn't echo out the <input> field, you just put it in the code, which will not work.
    2. You are echoing $var_x, but outside any attributes of the <input> tag. You echo it as the value; that's perfectly valid, but why is it after the "item_num" too? If you want it to be part of the item_num you need to change it to "item_num$var_x".
    3. Your open/close PHP tags are invalid. There must be at least one space after the <? and it is recommended that you use <?php instead of just <?
    4. You are not echoing out the <input> field, just putting it in the code.
    Change that whole line (in your post it's three) to this:
    PHP Code:
    echo "<input type='hidden' name='item_num' value='$var_x'>"
    This would create a hidden field with the name item_num and the value of $var_x, which would need to be set earlier in your code to be equal to anything. If you were posting the form using get you would get a URL with
    myscript.php?item_num=value-of-var_x
    Kevin


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
  •