Question: I've got a little bit of javascript embedded in my html (using a .aspx file). I want to perform some sort of if statement which then determines whether or not some sort of chart is displayed. This chart is displayed using html, and I'm assuming the if statement should be written in javascript. However, I don't really know how to "run" this html code from within java. It is basically just drawing a table. Any suggestions? I've seen document.write, but I've only seen that being used with single lines.

Answer: 
> 
> I'm assuming the if statement should be written in javascript
> 
> 
> 

Unless you are testing something that you can only find out out in JS, then do it server side in your ASP.NET code.

> 
> I don't really know how to "run" this html code from within 
> 
> 
> 

This is covered by chapter 47 of Opera's WSC: [Creating and modifying HTML](http://dev.opera.com/articles/view/creating-and-modifying-html/). You may wish to read some of the earlier chapters first.

> 
> java
> 
> 
> 

Java has about as much in common with JavaScript as Car does with Carpet. They are completely different programming languages.
Try writing the if statement in javascript and then rendering the html with the JQuery html() function. Just use a custom html id to locate where you want the html code to go. 

```
<div id = "custom-tag"> </div>

<script>
    if (true){
        $('#custom-tag').html('YourHtmlString');
    } else {
        $('#custom-tag').html('DifferentHtmlString');
    }
</script>

```

Read more about html() here: <http://api.jquery.com/html/> 

YourHtmlString & DifferentHtmlString is where you should store your custom html in string format. It will then be rendered wherever you included "div id = 'custom-id'

Hope this helps!