Jump to content

document.write() code


Recommended Posts

I was using the following document.write() code to display information in the "Head" section of a results page. This code no longer works due to support being dropped for document.write(). I know from your website that document.getElementById("mydiv[@field:UNIQUE]").innerHTML is the replacement but I am having a problem getting it work. If you could point out the correct syntax for one of the following document.write() lines, it would be greatly appreciated. 

<table width="600" border="0">
<tr>
<td width="130">
<script type="text/javascript">
/*
Following javascript displays fields not shown in the data table (values do not change). These fields do not need to be added in panel to left to be accessible via javascript. Since these fields on the results form are display only, those elements on the web page do not have ID’s so using document.getElementById will not work. To confirm this, the source of the page can be viewed in the URL provided when deploying the page.
*/
document.write('<span style="font-family:arial;color:#425A10;font-size:15px;"><b>Operator:&nbsp;&nbsp;</b></span>');
document.write('<p style="font-family:arial;color:#444444;font-size:12px;">[@field:first_name]&nbsp;[@field:last_name]</p>');
</script></td>

<td width="160"><script type="text/javascript">
document.write('<span style="font-family:arial;color:#425A10;font-size:15px;"><b>Operator ID:&nbsp;&nbsp;</b></span>');
document.write('<p style="font-family:arial;color:#444444;font-size:12px;">[@field:opnumber]</p>');
</script></td>

<td width="296"><script type="text/javascript">
document.write('<span style="font-family:arial;color:#425A10;font-size:15px;"><b>Employer:&nbsp;&nbsp;</b></span>');
document.write('<p style="font-family:arial;color:#444444;font-size:12px;">[@field:employer]</p>');
</script></td>
</tr>
</table>

Link to comment
Share on other sites

Here is an example to change document.write code from https://howto.caspio.com/tech-tips-and-articles/advanced-customizations/tech-tip-generating-geolocation-coordinates-from-web-form-submissions/ article:

1. Define an id of some type <p>, <span>, etc. outside the <script>.
2. Within the script, then add the innerHTML code.


<span id="error_message"> </span>
<script type='text/javascript'>
.
.
.
document.getElementById("error_message").innerHTML = "This Datapage require Standard Caspio Deployment for full functionality." ;
.
.
</script>


In your case, if I take one example:

<table width="600" border="0">
<tr>
<td width="130">
<span id="font_change"> </span>
<script type='text/javascript'>
document.getElementById("font_change").innerHTML='<span style="font-family:arial;color:#425A10;font-size:15px;"><b>Operator:&nbsp;&nbsp;</b></span>';

</script>


Please try the above format for all your document.write statements. 

I hope that helps.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...