将变量写入html页面 [英] write a variable to a html page

查看:150
本文介绍了将变量写入html页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道JavaScript,但我们的任务是编写一个脚本,将布尔变量的值更改为单词Yes。在一排桌子上。我一直在努力根据我对ActionScript的了解来实现这一目标。不用说,我没有成功!


## CUSTOM_SUB_MARKETEYE ##是一个从数据库中提取布尔结果的标记。它在为真时返回1,在为假时返回null。我需要将1转换为1。单词是并写下是字样在我的桌子上排成一排。


我意识到我的要求有多少,但如果有人能帮助我,我将永远感激不尽。我道歉,我只是不知道从哪里开始。我一直在寻找网络,并乞求一天半的好处,并且绝对没有在哪里。提前感谢任何有帮助的人! Julie


展开 | 选择 | Wrap | 行号

解决方案

欢迎来到TSDN!


您可以更改生成HTML代码的页面。如果可以,最好将一些ID添加到包含这些变量的表格单元格中。然后,您可以使用document.getElementById()访问它们。如果你不能,我可以考虑其他方法来做到这一点。



欢迎来到TSDN!


您可以更改生成HTML代码的页面。如果可以,最好将一些ID添加到包含这些变量的表格单元格中。然后,您可以使用document.getElementById()访问它们。如果你不能,我可以想到其他方法来做到这一点。



感谢您的回复。我可以在单元格中添加ID。喜欢这个?


[HTML]< table style =" height:148px;"边界=" 0" width =" 667">

< tbody>< tr>

< td width =" 177">< b> MarketEye< / b>< / td>

< td id =" market" BORDERCOLOR ="#FFFFFF" width =" 480"& nbsp;< b> ## CUSTOM_SUB_MARKETEYE ##< / b>< / td>

< / tr>

< tr>

< td>< b>< i> IP& amp; E Matters< / i>< / b>< / td>

< td id =" ipe" bordercolor =" #FFFFFF">& nbsp;< b> ## CUSTOM_SUB_IPE_MA TTERS ##< / b>< / td>

< / tr>

< tr>

< td>< b>技术研讨会系列& amp; QuikCasts< / b>

< br />< / td>

< td id =" technical" bordercolor =" #FFFFF">& nbsp;< b> ## CUSTOM_SUB_TECHNI CAL_SEMINAR_SERIES ##< / b>< / td>

< / tr>

< tr>

< td>< b> TTI促销电子邮件< / b>< / td>

< td id =" ;促销" bordercolor =" #FFFFF">& nbsp;< b> ## CUSTOM_SUB_PROMO_ EMAIL ##< / b>< / td>

< / tr>

< / tbody>< / table> [/ HTML]



感谢您的回复。我可以在单元格中添加ID。像这样?



是的,你可以。现在,您可以使用document.getElementById(" market")访问包含变量的表格单元格。要获取实际内容,可以使用innerHTML。这会给你一个字符串。您可以使用 replace()将布尔值替换为是/否


I don''t know JavaScript but have been tasked to write a script that will change the value of a Boolean variable to the word "Yes" on a table row. I have been trying to achieve this based on my knowledge of ActionScript. Needless to say, I have not been successful!

##CUSTOM_SUB_MARKETEYE## is a tag that pulls the Boolean result from a database. It returns 1 when it is true and null when it is false. I need to convert that "1" to the word "Yes" and write the word "Yes" to a row in my table.

I realize how much I am asking but would be eternally grateful if someone would help me with this. I appologize, I just don''t know where to start. I have been searching the web and begging favors for a day and a half and have gotten absolutely no where. Thanks in advance to anyone who will help! Julie


Expand|Select|Wrap|Line Numbers

解决方案

Welcome to TSDN!

Can you change the page which generates the HTML code. If you can, it would be good idea to add some IDs to the table cells which contain these variables. Then you can access them using document.getElementById(). If you can''t, I can think of other ways to do this.


Welcome to TSDN!

Can you change the page which generates the HTML code. If you can, it would be good idea to add some IDs to the table cells which contain these variables. Then you can access them using document.getElementById(). If you can''t, I can think of other ways to do this.

Thank you for your response. I can add IDs to the cells. Like this?

[HTML]<table style="height: 148px;" border="0" width="667">
<tbody><tr>
<td width="177"><b>MarketEye</b></td>
<td id="market" bordercolor="#FFFFFF" width="480">&nbsp;<b>##CUSTOM_SUB_MARKETEYE##</b></td>
</tr>
<tr>
<td><b><i>IP&amp;E Matters</i></b></td>
<td id="ipe" bordercolor="#FFFFFF">&nbsp;<b>##CUSTOM_SUB_IPE_MA TTERS##</b></td>
</tr>
<tr>
<td><b>Technical Seminar Series &amp; QuikCasts</b>
<br /></td>
<td id="technical" bordercolor="#FFFFFF">&nbsp;<b>##CUSTOM_SUB_TECHNI CAL_SEMINAR_SERIES##</b></td>
</tr>
<tr>
<td><b>TTI Promotional Emails</b></td>
<td id="promo" bordercolor="#FFFFFF">&nbsp;<b>##CUSTOM_SUB_PROMO_ EMAIL##</b></td>
</tr>
</tbody></table>[/HTML]


Thank you for your response. I can add IDs to the cells. Like this?

Yes, you can. Now you can access the table cell containing the variable using document.getElementById("market"). To get the actual contents, you can use innerHTML. This will give you a string. You can use replace() to replace the boolean value with Yes/No.


这篇关于将变量写入html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆