Problem with some JS

He has: 296 posts

Joined: May 2002

Hey,

My friend asked me to make a review script that is integrated into his forum. So far, it's working fine. Except getting the postbit edited. Right now I have http://www.anime-chaos.com/forums/[postbit_template]/index.htm, looks great. Down at the bottom is a table with the header "Characters", followed by a row with a blank text box and a link that says "Add". If you put a 1 in the box and click "Add" everything works fine EXCEPT that there should be three text boxes added: one next to each text that is added.

Snippet:

    <script type="text/javascript">
    <!--
    function Add() {
      to_add=document.REPLIER.charas_to_add.value;
      flg=0;
      for (var i=0;i<to_add.length;i++){
        cmp="0123456789"
        tst=to_add.substring(i,i+1)
        if (cmp.indexOf(tst)<0){
          flg++;
        }
      }
      if (flg!=0){
        alert("Field 'charas_to_add' is invalid");
      } else if (to_add=='') {
        alert("Field 'charas_to_add' is invalid");
      } else {
        document.REPLIER.charas_to_add.style.visibility="hidden";
        document.REPLIER.charas_to_add.style.position="absolute";
        document.REPLIER.charas_to_add.style.top="0";
        document.all.charas_to_add_a.style.visibility="hidden";
        document.all.charas_to_add_a.style.position="absolute";
        document.all.charas_to_add_a.style.top="0";
        document.REPLIER.c_name_1.style.visibility="visible";
        document.REPLIER.c_image_1.style.visibility="visible";
        document.REPLIER.c_bio_1.style.visibility="visible";
        var i=1;
        while (i <= to_add) {
          to_show = "c_"+i;
          to_show_name = "c_name_"+i;
          to_show_image = "c_image_"+i;
          to_show_bio = "c_bio_"+i;
          eval(to_show+'.style.visibility="visible"');
          eval('document.REPLIER.'+to_show_name+'.style.visibility="visible"');
          eval('document.REPLIER.'+to_show_image+'.style.visibility="visible"');
          eval('document.REPLIER.'+to_show_bio+'.style.visibility="visible"');
          eval(to_show+'.style.position="relative"');
          i++;
        }
      }
    }
    -->
    &lt;/script&gt;
    <table cellSpacing=1 cellPadding=0 width="65%" bgcolor="#666666" align=center border=0>
      <tr>
        <td>
          <table cellSpacing=1 cellPadding=4 width="100%" align=center border=0>
            <tr><td class="postfoot">
              Characters
            </td></tr>
            <tr><td class="row1">
              <input type="text" name="charas_to_add"> <a href="javascript:Add();" name="charas_to_add_a">Add</a>
              <span id="c_1" style="visibility: hidden; position: absolute; top: 0px;">
                Name: <input type="text" name="c_name_1"><br>
                Image: <input type="text" name="c_image_1"><br>
                Bio: <input type="text" name="c_bio_1"><br>
              </span>
            </td></tr>
          </table>
        </td>
      </tr>
    </table>
'
Thanks for any help you can provide!
necrotic

[James Logsdon]