Solved

Insert HTML DIV in Javascript

Posted on 2014-09-29
5
200 Views
Last Modified: 2014-09-30
I need to insert two divs in this javascript code but not sure how.

I would like to insert after the beggining of the script tag:

<div class="infobox-wrapper">
<div id="infobox">


And at the end:
</div></div>



<script type="text/javascript">
var poiAddress = " <?php echo $attorneysStuff['bizAddr'];?>, <?php echo $bizCity;?>, <?php echo $bizState;?>";
var poiHTML = ' <?php echo $attorneysStuff['bizName'];?><br><?php echo $attorneysStuff['bizAddr'];?>, <?php echo $attorneysStuff['bizCity'];?><br><?php echo $attorneysStuff['bizState'];?><br>Phone:<?php echo $attorneysStuff['bizPhone'];?>';
var poiZoomLevel = 12;
var infoHTML = "";

</script>

Open in new window

0
Comment
Question by:seopti
  • 2
  • 2
5 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 40350849
I think you're looking for document.write : https://developer.mozilla.org/en-US/docs/Web/API/document.write

But, today, it's not the right way to do that, it's a bit old school :)) IMHO
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40350984
If you actually mean to put them inside the script tags like below, that won't work right.  The <div>s won't be recognized and will cause errors in the javascript.
<script type="text/javascript">
<div class="infobox-wrapper">
<div id="infobox">
var poiAddress = " <?php echo $attorneysStuff['bizAddr'];?>, <?php echo $bizCity;?>, <?php echo $bizState;?>";
var poiHTML = ' <?php echo $attorneysStuff['bizName'];?><br><?php echo $attorneysStuff['bizAddr'];?>, <?php echo $attorneysStuff['bizCity'];?><br><?php echo $attorneysStuff['bizState'];?><br>Phone:<?php echo $attorneysStuff['bizPhone'];?>';
var poiZoomLevel = 12;
var infoHTML = "";
</div></div>
</script>

Open in new window

0
 

Author Comment

by:seopti
ID: 40351256
Dave, well that's the reason I'm posting here :)
0
 

Author Comment

by:seopti
ID: 40351258
Javascript is a dumb programming language, not even simple DIVS are possible. I don't know who invented this shitty language.
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40351283
In this scenario the script tag is INSIDE the BODY tag :
<body>
<script type="text/javascript">
document.write('<div class="infobox-wrapper">');
document.write('<div id="infobox">');
document.write('<?php echo $attorneysStuff['bizAddr'];?>, <?php echo $bizCity;?>, <?php echo $bizState;?>');
document.write('<?php echo $attorneysStuff['bizName'];?><br><?php echo $attorneysStuff['bizAddr'];?>, <?php echo $attorneysStuff['bizCity'];?><br><?php echo $attorneysStuff['bizState'];?><br>Phone:<?php echo $attorneysStuff['bizPhone'];?>');
var poiZoomLevel = 12;
var infoHTML = "";
document.write('</div></div>');
</script>

Open in new window

0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question