1 Replies - 474 Views - Last Post: 05 December 2011 - 08:16 PM

#1 guyfromri  Icon User is offline

  • D.I.C Addict

Reputation: 46
  • View blog
  • Posts: 817
  • Joined: 16-September 09

Script to create an input inside a div only works on certain divs?

Posted 05 December 2011 - 07:41 PM

Hey guys!!

I'm losing my mind here...I have a really simple script that creates an input box inside a div id -- it was working great..then I added in a piece where it would show other peoples existing replies and create the box at the top but under the original post...sometimes it works on the first div, other times it works on every third div but isn't working all the way around and I'm beating my head against a wall here...

Here's the javascript
function create_reply_input(post_id, db_id){ 
    if(document.getElementById(post_id.id).innerHTML.indexOf('post_rep_box')==-1)
      document.getElementById(post_id.id).innerHTML += "<div id='post_rep_form_" + post_id.id + "'><center><form name='post_rep_form' action='javascript:void(0);' onsubmit='return create_post_reply(" + post_id.id + "," + db_id + ");'><b>Public Reply </b><input type='text' name='post_rep_box' id='post_rep_box_" + post_id.id + "' size='50'/><input type='button' value='Reply' onclick='return create_post_reply(" + post_id.id + "," + db_id + ");'/></form></center></div>"; 
  }



Here's the HTML output so you can see where I'm assigning it
<div class='loop_con_main'>
  <div class='loop_container' id='post_0'>
     <div class='loop_int_con_left'>
         <img src='http://mysite.com/user_images/1_MTc3NTAzNDcyOQ==' class='loop_pic'/>
      </div>
      <div class='loop_int_con_right'>
          <div class='p_name'>James P McGovern</div><br/> 
                Look a real live post<br/>
          <div class='p_date'>12/05/2011 07:56:04 PM</div>
      </div>
      <div class='loop_int_con_far_right'>
          <ul>                        
              <li><a href='javascript:create_reply_input(post_0, 29);'>Reply</a></li>
              <li><a href='http://mysite.com/scripts/posts/deactivate_post.php?post_id=29&last_page=mysite.com/login_index.php'>Remove</a></li>
          </ul>
      </div>
        <div class='clear'></div>
  </div>
  <div class='clear'></div>
</div>



As always, thanks in advance!!!

Is This A Good Question/Topic? 0
  • +

Replies To: Script to create an input inside a div only works on certain divs?

#2 guyfromri  Icon User is offline

  • D.I.C Addict

Reputation: 46
  • View blog
  • Posts: 817
  • Joined: 16-September 09

Re: Script to create an input inside a div only works on certain divs?

Posted 05 December 2011 - 08:16 PM

::::SOLVED::::

Sorry guys -- I posted prematurely..turns out it was a problem with my PHP output and I just caught it!!

:) :stupid:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1