473,394 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

write a variable to a html page

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
  1. <script type="text/javascript"><!--
  2. document.getElementById("##CUSTOM_SUB_MARKETEYE##");
  3. var Marketeye = "##CUSTOM_SUB_MARKETEYE##";
  4. if (Marketeye == true) 
  5. {
  6. Marketeye = "Yes";
  7. }
  8. else
  9. {
  10. Marketeye = "No";
  11. }
  12. // --></script>
This is my html document. Where the ##CUSTOM_SUB...## tags are in my html is where I need to write the converted variable. I do not have to have the tags there.

[HTML]<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body
<p>&nbsp;</p>

<div class="mainDiv" align="center">
<img src="http://www.mycmdirect.com/webimages/directweb/7/email_header.jpg" alt="TTI - Never Short on Solutions" title="TTI, Inc. - Never Short on Solutions" height="144" width="669" />
<table style="height: 392px;" align="center" border="0" cellpadding="1" cellspacing="2" width="669">
<tbody><tr>
<td colspan="2" class="promoLine" height="29" width="706">February 28, 2008 </td>
</tr>
<tr>
<td align="left" valign="top"><p>&nbsp;</p>
<p>Thank you, ##FIRSTNAME##,<b> </b>for your interest in TTI's free eNewsletter service. Our records indicate you subscribed to the following electronic newsletters and/or emails:</p>
<table style="height: 148px;" border="0" width="667">
<tbody><tr>
<td width="177"><b>MarketEye</b></td>
<td bordercolor="#FFFFFF" width="480">&nbsp;<b>##CUSTOM_SUB_MARKETEYE##</b>&lt;%= Marketeyeyn%&gt;<b> </b><span style="color: navy; font-family: Arial; font-size: x-small;"><span style="font-size: 10pt; color: navy; font-family: Arial;"></span></span></td>
</tr>
<tr>
<td><b><i>IP&amp;E Matters</i></b></td>
<td bordercolor="#FFFFFF">&nbsp;<b>##CUSTOM_SUB_IPE_MA TTERS##</b></td>
</tr>
<tr>
<td><b>Technical Seminar Series &amp; QuikCasts</b>
<br /></td>
<td bordercolor="#FFFFFF">&nbsp;<b>##CUSTOM_SUB_TECHNI CAL_SEMINAR_SERIES##</b></td>
</tr>
<tr>
<td><b>TTI Promotional Emails</b></td>
<td bordercolor="#FFFFFF">&nbsp;<b>##CUSTOM_SUB_PROMO_ EMAIL##</b></td>
</tr>
</tbody></table>

<p><br />
We appreciate you choosing TTI, Inc. as your preferred information source. You should receive your first email within the next 5-7 business days.<br />
<br />
Regards,<br />
<br />
TTI, Inc.</p>
<br />
</td>
</tr>
<tr>
<td colspan="2" class="submitRow"><div class="style1" align="center">&copy;2008 TTI, Inc. 2441 Northeast Pkwy, Fort Worth, TX 76106</div></td>
</tr>
<tr>
<td colspan="2" class="submitRow"><div class="style1" align="center"></div><br /></td>
</tr>
</tbody></table>

</div>
</body>
</html>[/HTML]
Mar 6 '08 #1
10 1853
acoder
16,027 Expert Mod 8TB
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.
Mar 6 '08 #2
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]
Mar 6 '08 #3
acoder
16,027 Expert Mod 8TB
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.
Mar 6 '08 #4
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.
I tried this but it did not work. Am I missing a step or is my syntax wrong?

Thanks again for helping me!!!

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. function changeText(){
  4.     document.getElementById("market").innerHTML = '##CUSTOM_SUB_MARKETEYE##';
  5.  if (##CUSTOM_SUB_MARKETEYE## == true) 
  6. {
  7. str.replace(/##CUSTOM_SUB_MARKETEYE##/, "Yes"));
  8. }
  9. else
  10. {
  11. str.replace(/##CUSTOM_SUB_MARKETEYE##/, "No"));
  12.  
  13. }
  14.  
  15. window.onload='changeText()' value='Change Text'/>
  16. </script>
Mar 6 '08 #5
I tried this but it did not work. Am I missing a step or is my syntax wrong?

Thanks again for helping me!!!

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. function changeText(){
  4.     document.getElementById("market").innerHTML = '##CUSTOM_SUB_MARKETEYE##';
  5.  if (##CUSTOM_SUB_MARKETEYE## == true) 
  6. {
  7. str.replace(/##CUSTOM_SUB_MARKETEYE##/, "Yes"));
  8. }
  9. else
  10. {
  11. str.replace(/##CUSTOM_SUB_MARKETEYE##/, "No"));
  12.  
  13. }
  14.  
  15. window.onload='changeText()' value='Change Text'/>
  16. </script>
This doesn't work either. Am I getting closer?

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript"><!--
  2. function changeText(){
  3. var mystr=document.getElementById("market").innerHTML = '##CUSTOM_SUB_MARKETEYE##';
  4.  if (mystr == true) 
  5. {
  6. mystr.replace(/mystr/, "Yes");
  7. }
  8. else
  9. {
  10. mystr.replace(/mystr/, "No");
  11.  
  12. }
  13. window.onload='changeText()';
  14. // --></script>
Mar 6 '08 #6
acoder
16,027 Expert Mod 8TB
Try something like:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function changeText() {
  3.   var market = document.getElementById("market");
  4.   var mystr = market.innerHTML;
  5.   mystr = mystr.replace(/true/, "Yes");
  6.   mystr = mystr.replace(/false/, "No");
  7.   market.innerHTML = mystr;
  8. }
  9. window.onload=changeText;
  10. </script>
Mar 7 '08 #7
Thanks so much for continuing to help me! I understand your code perfectly now but it still does not work. I think it is because I am trying to replace a tag (##CUSTOM_SUB_MARKETEYE##) which is pulling data from a data base. Can you think of anything else I could try? Thanks again. Julie



Expand|Select|Wrap|Line Numbers
  1. <p><script type="text/javascript"><!--
  2. function changeText() {
  3.   var market = document.getElementById("market");
  4.   var mystr = market.innerHTML;
  5.   mystr = mystr.replace(/true/, "Yes");
  6.   mystr = mystr.replace(/false/, "No");
  7.   market.innerHTML = mystr;
  8. }
  9. window.onload=changeText;
  10. // --></script>
  11. </p>
[HTML]<p>&nbsp;</p>

<div class="mainDiv" align="center">
<img src="http://www.mycmdirect.com/webimages/directweb/7/email_header.jpg" alt="TTI - Never Short on Solutions" title="TTI, Inc. - Never Short on Solutions" height="144" width="669" />
<table style="height: 392px;" align="center" border="0" cellpadding="1" cellspacing="2" width="669">
<tbody><tr>
<td colspan="2" class="promoLine" height="29" width="706">March 7, 2008 </td>
</tr>
<tr>
<td align="left" valign="top"><p>&nbsp;</p>
<p>Thank you, ##FIRSTNAME##,<b> </b>for your interest in TTI's free eNewsletter service. </p>
<table><tbody><tr><td id="market">##CUSTOM_SUB_MARKETEYE##</td></tr></tbody></table>

<p><br />
We appreciate you choosing TTI, Inc. as your preferred information source. You should begin receiving the email subscriptions within the next 5-7 business days.<br />
<br />
Regards,<br />
<br />
TTI, Inc.</p>
<br />
</td>
</tr>
<tr>
<td colspan="2" class="submitRow"><div class="style1" align="center">&copy;2008 TTI, Inc. 2441 Northeast Pkwy, Fort Worth, TX 76106</div></td>
</tr>
<tr>
<td colspan="2" class="submitRow"><div class="style1" align="center"></div><br /></td>
</tr>
</tbody></table>

</div>[/HTML]
Mar 7 '08 #8
acoder
16,027 Expert Mod 8TB
Thanks so much for continuing to help me! I understand your code perfectly now but it still does not work. I think it is because I am trying to replace a tag (##CUSTOM_SUB_MARKETEYE##) which is pulling data from a data base. Can you think of anything else I could try? Thanks again. Julie
I see it's 1 and 0 instead of true/false. Replace true and false in the regexp (/true/ and /false/) with 1 and 0 respectively.

Just a note that you could do this on the server-side with whatever language is generating the page and converting the tags to 1 and 0.
Mar 7 '08 #9
It worked! Thanks so very much for your patience and your assistance! I am eternally grateful!

Julie
Mar 9 '08 #10
acoder
16,027 Expert Mod 8TB
No problem. Glad it worked for you. Post again if you have any more questions.
Mar 9 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: db | last post by:
Hello all, I hope this is the correct newsgroup for this question. Does anybody know how I can write a html-header with python(cgi)? The problem is, I have a few html templates in which I have...
8
by: Greg Brant | last post by:
my script is document.write("<!-- #include virtual\"http://www.where-ever.com/whatevere.html\" -->") but in the html (view source) i get ---------------------------------------------------...
8
by: Jack | last post by:
Hi, Here is my problem: I am logging in to a page, where the page retrieves a record from a database. The text boxes are used in the display formto let the users update the fields, if they...
2
by: Ralph Krausse | last post by:
I want to create my own kind of counter, for myself. I have a resume page on my site. I want to know how many people go there but dont want to 'go there' myself because I don't want to increase the...
14
by: Eli | last post by:
I've got a script that I'm trying to debug which uses document.write() to place HTML within a page. In both IE6 and Firefox when I view source, I see only the script itself and not any HTML as...
4
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400,...
2
by: Steve Franks | last post by:
What is the proper/best way to dynamically change the HTML written out to the browser based on the value from a variable in a code behind page? For instance, I have test.aspx.vb as a code behind...
18
by: Ed Jay | last post by:
<disclaimer>js newbie</disclaimer> My page has a form comprised of several radio buttons. I want to poll the buttons to determine which button was selected and convert its value to a string. I...
8
by: '69 Camaro | last post by:
Perhaps I'm Googling for the wrong terms. Does anyone have links to examples of the syntax necessary to read the HTML on another Web page when that HTML is produced from JavaScript using the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.