Solved

Insert HTML DIV in Javascript

Posted on 2014-09-29
5
206 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

752 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