Results 1 to 4 of 4

Thread: adding delete button or check box to form

  1. #1
    Join Date
    Jul 2012

    adding delete button or check box to form


    I have a form that that will upload an image with comments saving to an xml file.

    The page also list all the images and comments in the xml page.

    What I am having trouble with is creating a delete button or check box to delete a record in the xml file via the php form.

    Here is the Form:
                <form action="playlistaction.php" method="post" enctype="multipart/form-data">
         <td colspan="2"class="labelcell"><label for="title">Title:</label></td>
         <td colspan="2"class="fieldcell"><input type="text" id="title" name="title"  tabindex="1"/></td>
         <td colspan="2"class="labelcell"><label for="description">Description:</label></td>
         <td colspan="2"class="fieldcell"> <input type="text" id="description" name="description"  tabindex="2"/><br />
         <td colspan="2"class="labelcell"><label for="userfile">Image Upload:</label></td>
         <td colspan="2"> <input name="userfile" type="file" id="userfile" tabindex="2"/><br />
       <tr style="display:none">
     <td colspan="2"class="labelcell"><label for="img">Image</label></td>
        <td colspan="2" class="fieldcell"> <input type="text" id="img" name="img"  tabindex="4"></td>
       <td colspan="4"><input type="submit" name="upload" class="box" value="Submit" tabindex="5" /></td>
    <h2>Current entries:</h2>
    <p>Title - Description - Image  </p>
    <div style="border:1px solid black; overflow:auto; height:400px; width:800px">
    $doc = new DOMDocument();
    $doc->load( 'photoGallery.xml' );
    $gallery = $doc->getElementsByTagName( "images" );
    foreach( $gallery as $images )
      $artists = $images->getElementsByTagName( "title" );
      $title = $artists->item(0)->nodeValue;
      $titles= $images->getElementsByTagName( "description" );
      $description= $titles->item(0)->nodeValue;
      $tmbs = $images->getElementsByTagName( "tmb" );
      $tmb = $tmbs->item(0)->nodeValue;
      $imgs = $images->getElementsByTagName( "img" );
      $img = $imgs->item(0)->nodeValue;
      echo "<b>$title - $description - $tmb\n</b><br>";}?>
    I've tried to add this to the echo but it brakes the code.
      echo "<b>$title - $description - $tmb <input name="delete" type="button" value=" ">\n</b><br>";}?> 
    Thank in advance.

  2. #2
    Join Date
    Jul 2012

    Got the button working but need to echoa variable in a text box


    I finally got the button at the end of the data display from my xml file. I'm surprised no one was able to figure this out...

    Anyway, now that that is done

    echo "<b>$title - $description - $tmb <input name=\"delete\" type=\"button\" value=\" \">\n</b><br>";}?>
    I would like to place variable $title in a text boxes in order to make changes. I will be adding an update button next to the delete button.

    This is what I did and of course it broke

    echo "<b>?> <input name="tupdate" type="text" id="tupdate" value="<?php echo "$title"; ?>" /> - $description - $tmb <input name=\"delete\" type=\"button\" value=\" \">\n</b><br>";}?>
    Where am going wrong? ... redemption time!

  3. #3
    Join Date
    Aug 2004
    Well, to start off with, this ain't gonna work:
    PHP Code:
    echo "<b>?> 
    How about just doing:
    PHP Code:
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  4. #4
    Join Date
    Jul 2012
    your 2nd post ...

    PHP Code:
    echo "<input name='tupdate' type='text' id='tupdate' value='{$title}' />
            <b> - 
    {$description} - {$tmb} </b>
            <input name='delete' type='button' value=''><br>"

    Last edited by mistin.ca; 07-28-2012 at 09:11 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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