Embedding HTML into Javascript

HI there im trying to embd some HTML, specifically an input box and a date picker into a javascript call so that when a user clicks a link it dynamically generates the form elements to the screen. The generation seems to work fine however when I click the datepicker box to bring up the pop up it gives me an javascript error.

Error: syntax error
Source File: http://ictintranet/commsform/defaultnew.asp
Line: 1, Column: 9
Source Code:
winBRopen(

I have included all the code in the below attatchment so you can test.

Any help is always appreciated.
//Javascript fuction
function addInput(divName){
    
var newdiv = document.createElement('div');
newdiv.innerHTML = "<textarea cols='50' rows='3' name='event[]'>";
newdiv.innerHTML = newdiv.innerHTML + "<input type='text' name='fromdate[]' maxlength='10' size='20'><a href='javascript:;' onClick='winBRopen('cal_popup.asp?FormName=FormName&amp;FieldName=eventdate&amp;','popup_cal','241','206','no','no')'><img src='img/cal.gif' alt='Pick A Date' border='0' class='DatePicker' align='middle'/></a>";
document.getElementById(divName).appendChild(newdiv);
 
}
 
//HTML
 
<input type="button" value="Add another text input" onClick="addInput('dynamicInput');">

Open in new window

LVL 1
MayoorPatelAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vibrazyCommented:
Try this

<script>
//Javascript fuction
function addInput(divName){
    
var newdiv = document.createElement('div');
newdiv.innerHTML = "<textarea cols='50' rows='3' name='event[]'>";
newdiv.innerHTML = newdiv.innerHTML + "<input type='text' name='fromdate[]' maxlength='10' size='20'><a href='javascript:;' onClick=\"winBRopen('cal_popup.asp?FormName=FormName&amp;FieldName=eventdate&amp;','popup_cal','241','206','no','no')\"><img src='img/cal.gif' alt='Pick A Date' border='0' class='DatePicker' align='middle'/></a>";
document.getElementById(divName).appendChild(newdiv);
 
}
 </script>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MayoorPatelAuthor Commented:
Awesome worked a treat
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.