www.webdeveloper.com
Results 1 to 3 of 3

Thread: Large string mixed with PHP won't work

  1. #1
    Join Date
    Mar 2010
    Posts
    2

    Angry Large string mixed with PHP won't work

    Hey guys,

    I have posted this somewhere else to no avail, maybe you guys can help me out.

    I converted the whole thing to php, and it looks better when looking at the source code, but it still doesn't work. Does anyone see anything wrong with the code here:

    Here's the php that produces the string:

    Code:
    <?php
    echo 'var inner = \'<colgroup><col span="1" width="250" /><col span="1" width="\
    200" /></colgroup><tr><td class="leftAlign">Letter of Recommendation</td><td>';
    if(mysql_num_rows($f) != 0) {
        echo '<select name=\"recommendation_archive\">';
        include "includes/objects/files_drpDwn.php";
        echo "</select>";
    }
    else {
        echo "No files in archives.";
    }
    echo '</td><td><input name="recommendation_upload" type="file" /></td></tr>';
    if(mysql_num_rows($f) != 0) {
        mysql_data_seek($f, 0);
    } // allow for repeat of query                                                  
    echo '<tr><td class="leftAlign">Letter of Recommendation</td><td>';
    if(mysql_num_rows($f) != 0) {
        echo "<select name=\"recommendation_archive2\">";
        include "includes/objects/files_drpDwn.php";
        echo "</select>";
    }
    else {
        echo "No files in archives.";
    }
    echo '</td><td><input name="recommendation_upload2" type="file" /></td></tr>';
    if(mysql_num_rows($f) != 0) {
        mysql_data_seek($f, 0);
    }// allow for repeat of query                                                   
    echo '<tr><td class="leftAlign">Acceptance Letter</td><td>';
    if(mysql_num_rows($f) != 0) {
        echo "<select name=\"acceptance_archive\">";
        include "includes/objects/files_drpDwn.php";
        echo "</select>";}
    else {
        echo "No files in archives.";
    }
    echo '</td><td><input name="acceptance_upload" type="file" /></td></tr>\';';
    ?>
    Here's the output:
    Code:
    var inner = '<colgroup><col span="1" width="250" /><col span="1" width="200" /></colgroup><tr><td class="leftAlign">Letter of Recommendation</td><td><select name=\"recommendation_archive\"><option value="Choose...">Choose...</option><option value="8u-03262010-u7p">transcript_uploadyv4vg</option>  <option value="nf-03262010-lsk">resume_uploadrogpa</option>  </select></td><td><input name="recommendation_upload" type="file" /></td></tr><tr><td class="leftAlign">Letter of Recommendation</td><td><select name="recommendation_archive2"><option value="Choose...">Choose...</option><option value="8u-03262010-u7p">transcript_uploadyv4vg</option>  <option value="nf-03262010-lsk">resume_uploadrogpa</option>  </select></td><td><input name="recommendation_upload2" type="file" /></td></tr><tr><td class="leftAlign">Acceptance Letter</td><td><select name="acceptance_archive"><option value="Choose...">Choose...</option><option value="8u-03262010-u7p">transcript_uploadyv4vg</option>  <option value="nf-03262010-lsk">resume_uploadrogpa</option>  </select></td><td><input name="acceptance_upload" type="file" /></td></tr>';
    And here is the complete function in case I am missing something:
    Code:
    if(value == 1) {
        var continueEssay = document.getElementById('essayExplanation');
        var newdiv = document.createElement('table');
        var continueInfo = document.getElementById('continuing');
    
        var divClassName = 'filesTable';
        newdiv.setAttribute('class',divClassName);
    
        var divIdName = 'files';
        newdiv.setAttribute('id',divIdName);
    
          <?php
                echo 'var inner = \'<colgroup><col span="1" width="250" /><col span\
    ="1" width="200" /></colgroup><tr><td class="leftAlign">Letter of Recommendatio\
    n</td><td>';
        if(mysql_num_rows($f) != 0) {
            echo '<select name=\"recommendation_archive\">';
            include "includes/objects/files_drpDwn.php";
            echo "</select>";
        }
        else {
            echo "No files in archives.";
        }
        echo '</td><td><input name="recommendation_upload" type="file" /></td></tr>\
    ';
        if(mysql_num_rows($f) != 0) {
            mysql_data_seek($f, 0);
        } // allow for repeat of query                                              
        echo '<tr><td class="leftAlign">Letter of Recommendation</td><td>';
        if(mysql_num_rows($f) != 0) {
            echo "<select name=\"recommendation_archive2\">";
            include "includes/objects/files_drpDwn.php";
            echo "</select>";
        }
        else {
            echo "No files in archives.";
        }
        echo '</td><td><input name="recommendation_upload2" type="file" /></td></tr\
    >';
        if(mysql_num_rows($f) != 0) {
            mysql_data_seek($f, 0);
        }// allow for repeat of query                                               
        echo '<tr><td class="leftAlign">Acceptance Letter</td><td>';
        if(mysql_num_rows($f) != 0) {
            echo "<select name=\"acceptance_archive\">";
            include "includes/objects/files_drpDwn.php";
            echo "</select>";}
        else {
            echo "No files in archives.";
        }
        echo '</td><td><input name="acceptance_upload" type="file" /></td></tr>\';'\
    ;
          ?>
    
            newdiv.innerHTML = inner;
            ni.appendChild(newdiv);
            continueEssay.removeChild(continueInfo);
    }
    Basically the only errors occur when trying to attach this string in IE. I can't see an error in the string itself or the php, but let me know if you guys see an issue with the output. Thanks.

    --

    Greg

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    IE won't allow a partial table to be inserted into a table. Either create a complete table as string and insert using innerHTML, or create the table using valid DOM methods.

    MS innerHTML property
    To change the contents of the table, tFoot, tHead, and tr elements, use the table object model described in Building Tables Dynamically. However, to change the content of a particular cell, you can use innerHTML.
    Incidentally, html strings should have the forward slash escaped: http://www.w3.org/TR/REC-html40/inte....html#h-18.2.4
    Last edited by Fang; 03-27-2010 at 02:58 PM.

  3. #3
    Join Date
    Mar 2010
    Posts
    2

    Thank you

    That was it, it's kind of wierd because the object I was telling it to create was a table, so in the end - with the new object and the innerHTML you would have a complete table. In any case - thanks for the help.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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



Recent Articles