SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict
    Join Date
    Feb 2005
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    why value is not being set to zere

    I use the following code to add another row in my table for a form.
    How do i make the file input field go blank, cause now it copies the file location when i use the function


    Code:
    PHP Code:
    function addpicture()
    {
    var 
    newRow document.getElementById("foto").cloneNode("true");
    newRow.value "";
    var 
    row2 document.getElementById("addpicture");
    document.getElementById("tablebody").insertBefore(newRow,row2);


  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Try newRow.innerHTML="";

    Although I'm not exactly sure. A relevant html code would help.
    Saul

  3. #3
    SitePoint Addict
    Join Date
    Feb 2005
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <tr id="foto"><td></td><td><input type="file" name="foto[]" size="15"></td></tr

  4. #4
    SitePoint Addict
    Join Date
    Feb 2005
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry, how do i access the input element in the row?

  5. #5
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try
    Code:
    newRow.getElementsByTagName('input')[0].value = '';
    Btw, don't clone things with an ID, because each ID should be unique
    "Never imagine yourself not to be otherwise than what
    it might appear to others that what you were or might
    have been was not otherwise than what you had been
    would have appeared to them to be otherwise."

  6. #6
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You want to create the new row and put form input element in that row then access the new created element. Am i right? I think you can access the input element in the same usual way. I have done it before. If you mean like that i will post the code.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  7. #7
    SitePoint Addict
    Join Date
    Feb 2005
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Solution 1
    newRow.childNodes[1].childNodes[0].value = "";

    Solution 2
    newRow.getElementsByTagName('input')[0].value = '';


    I know about the problems with cloning ids however there is no function to easily find me my class. There's no get element by class. Only get elements by class. But indeed i should be able to use that.


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
  •