简体   繁体   中英

How to put script inside of script

I'm trying to figure out how I can make my form popup when someone hits yes. How do I incorporate this...?

Here's the JSFiddle: http://jsfiddle.net/VqqWW/

Here's the form:

<script type="text/javascript" src="http://form.jotform.us/jsform/32217646901149"></script>

I've tried putting,

if (q1 == "Yes") {
      document.getElementById("linkDiv").innerHTML = "<script type="text/javascript" src="http://form.jotform.us/jsform/32217646901149" />";
    }

That doesn't seem to work and I've also tried putting the code somewhere else in the head and linking it to that script but I'm not sure what's wrong.

function loadForm(){
    var fileref = document.createElement('script')
    fileref.setAttribute("type","text/javascript")
    fileref.setAttribute("src", "http://form.jotform.us/jsform/32217646901149")
}

Stole this from this site .

I'm not sure what you have done in that jotform script. However instead of creating new script files, generate the form(jotform) dynamically and add it in the innerHTML or make a reference variable to script and call it here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM