/    Sign up×
Community /Pin to ProfileBookmark

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>’;’;
?>[/CODE]

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>’;
[/code]

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);
}
[/code]

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

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangMar 27.2010 — 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 propertyTo 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 [B]innerHTML[/B].[/QUOTE]

Incidentally, html strings should have the forward slash escaped: http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.4
Copy linkTweet thisAlerts:
@gregwhitworthauthorMar 28.2010 — 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.
×

Success!

Help @gregwhitworth spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...