Page 1 of 1

Simple: How do you show large amounts of HTML easily with JS

Posted: Fri Sep 10, 2010 10:30 am
by lavaeagle
I have to generate a lot of HTML with some Javascript DOM to make a form, so when the user wants another upload spot or something they can just click add.

Thats not the problem I know how to do that, but I don't want to go through the html I'm generating and put \ in front of every single quotation mark.

For example in php I might:

Code: Select all

<? while ( $fish = 2 ){
 ?>
     A lot of HTML that will never stop!
<? 
} ?>
Note the ?> HTML STUFFS <?

Thank you!

Re: Simple: How do you show large amounts of HTML easily wit

Posted: Fri Sep 10, 2010 1:07 pm
by AbraCadaver
You'll have to give an example as I don't see where or when you will need to escape quotes:

[text]var html = '<form method="post" action="index.php">';[/text]

Re: Simple: How do you show large amounts of HTML easily wit

Posted: Fri Sep 10, 2010 1:20 pm
by lavaeagle

Code: Select all


<?

//include('inc/sql.php');

?>

<style type="text/css">
    .dynamicDiv {
    width:200px;
    height:100px;
    border:solid 1px #c0c0c0;
    background-color:#e1e1e1;
    font-size:11px;
    font-family:verdana;
    color:#000;
    padding:5px;
    }
</style>

<script type="text/javascript" language="javascript">
    function createDiv()
    {
        var divTag = document.createElement("div");
        divTag.id = "div1";
        divTag.setAttribute("align","center");
        divTag.style.margin = "0px auto";
        divTag.className ="dynamicDiv";
        divTag.innerHTML = "I have a lot of html and possible database stuff that would create a form right here, kind of like when you add a new upload file submit.";
        document.body.appendChild(divTag);
    }
</script>

    <p align="center">
        <b>Click this button to create div element dynamically:</b>
        <input id="btn1" type="button" value="create div" onclick="createDiv();" />
    </p>