Solved

Insert HTML DIV in Javascript

Posted on 2014-09-29
5
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

630 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