-1

I'm trying to create some javascript code that will display a javascript form (from formstack.com) on my website certain days of the week. However I can't seem to get it working. I think the first portion is correct, but when it gets to having javascript code to display other javascript I'm confused. Please help!!! Thanks

<head>
<script type="text/javascript">

var theDate = new Date();
var dayOfWeek = theDate.getUTCDay();

// Returns true if the restaurant is open
function isOpen()
{
    //I'll fill this in later, for now, return true
    return true;
}
</script>

</head><body>
<script type = "text/javascript">
if(isOpen())
{
<script type="text/javascript" src="http://www.formstack.com/forms/js.php?1134414-uqmj2UXxEw-v2"></script><noscript>
<a href="http://www.formstack.com/forms/CampusEnterprises-chopped_greens_order_form__copy" title="Online Form">
Online Form - Chopped Greens Order Form- COPY</a>
}
</script>
</body>
2
  • 3
    You cannot nest <script> tags in <script> tags. Commented Nov 5, 2011 at 21:01
  • 1
    And there is no need to in this case. Just place the external reference above the script for isOpen() Commented Nov 5, 2011 at 21:03

1 Answer 1

3

You're trying to display raw HTML inside JavaScript which won't work.

<script type="text/javascript">
if(isOpen())
{
    document.write( '<script type="text/javascript" src="http://www.formstack.com/forms/js.php?1134414-uqmj2UXxEw-v2"></script>' );
}
</script>

That said, even better would be to use a server-side language instead of JavaScript for things like this.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.