JavaScript - Documents Not Downloading In Js
I am working within phpZend CMS and have a page where you can download pdf's after checking the box agreeing to the rules & regulations. For some reason, while I can get the message requiring the box be checked to appear for all of the documents, once the box is checked I can only get the first document to download. Below is the code I am trying to use.
<?php echo $this->partial('partials/_left-nav.phtml', $this->leftnav_data); ?> <script language="JavaScript" type="text/JavaScript"> function legal() { if (document.getElementById('chk1').checked) { document.getElementById('subm').onclick = function(){ window.open('http://dev.joico-hair.com/lounge_docs/care/care_colorEndure_Guide.pdf'); } } else { alert("Please read the terms and legal statement and check the box to download the pdf"); } } function legaltwo() { if (document.getElementById('chk1').checked=='submtwo') { document.getElementById('submtwo').onclick = function(){ window.open('http://dev.joico-hair.com/lounge_docs/care/care_colorEndure_Sheet_Violet.pdf'); } } else { alert("irving"); } } function legalthree() { if (document.getElementById('chk1').checked=='submthree') { document.getElementById('submthree').onclick = function(){ window.open('http://dev.joico-hair.com/lounge_docs/care/care_downloadAll_colorEndure.pdf'); } } else { alert("fred"); } } </script> <link href="/css/lounge.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); } </script> <style type="text/css"> #inner_details { background-image: url(/images/Lounge/messageBox_colorEndureCare.png); height:510px; width:450px; } #inner_text { height:400px; width:375px; margin-top:80px; margin-bottom:15px; margin-left:30px; padding-right:10px; color:#ffffff; overflow:auto; } .download { margin-top:20px; } .thumbs { width:50px; height:63px; display: inline; vertical-align: top; margin-right: 10px; } </style> <title>download vero</title> <div id="detail_content"> <div id="inner_details"> <div id="inner_text"> The brand designed to promote the tonal integrity and color longevity, use these ads so your clients know to use Color Endure to preserve their haircolor. <br /><br /> <strong>NOTE:</strong> To download the pdf's you MUST first read and agree to the <a style="color:#cf993f;"href="#" onclick="MM_openBrWindow('http://www.joico.com/stile_legal','','width=500,height=500')">Joico S.T.I.L.E. Bylines</a>. <br /><br /> <form action="#" id="form1" > <input type="checkbox" id="chk1" onclick="legal()" /> By checking here I confirm that I have read and agree to the above bylines as stated.</form> <div class="download"> <a href='' id="subm" onclick="legal()"><img src="/images/Lounge/care/thumb_care_colorEndure_Guide.jpg" border="0" class="thumbs"/></a>Color Endure Guide </div> <div class="download"> <a href='' id="submtwo" onclick="legaltwo()"><img src="/images/Lounge/care/thumb_care_colorEndure_Sheet_Violet.jpg" border="0" class="thumbs"/></a>Color Endure Violet Sell Sheet </div> <div class="download"> <a href='' id="submthree" onclick="legalthree()"><img src="/images/Lounge/downloadAll.jpg" border="0" class="thumbs"/></a>Download all Color Endure Materials here </div> </div> </div> </div> Similar TutorialsI am trying to write a report-generator to collect user-comments from a list of external HTML files. User-comments are wrapped in < span> elements. Can this be done using JavaScript? The files are all available locally and I am using file:// protocol for the access. Here's my attempt: Code: function generateCommentReport() { var files = document.querySelectorAll('td a'); //Files to scan are links in an HTML table var outputWindow = window.open(); //Output browser window for report for(var i = 0; i<files.length; i++){ //Open each file in a browser window win = window.open(); win.location.href = files[i].href; //Scan opened window for 'comment's comments = win.document.querySelectorAll('.comment'); for(var j=0;j<comments.length;j++){ //Add to output report outputWindow.document.write(comment[i].innerHTML); } } } Hi, I have no clue on how to program the following using JavaScript: I want the user to be able to click a button or link in order to download the content of a <div id="query"> as a .sql file. I assume the variable for the writing to be document.getElementById('query').textContent (or perhaps .innerHTML) but I have absolutely no idea what the command for writing and downloading should be, nor have I been able to find any good tutorial/explenation on that using Google (yes I've tried myself first) Thanks in advance, Venidrad Well just came to notice this lack of tools on javascript to manage uploads or downloads while working on my new project. I've been trying different ways to get the upload progress, stimated time left, upload speed average, but everything I have done was somehow dirty. I have spent the last two days trying to get a flash file do this for me, and there is always an issue and you have to get a tricky solution to get something that should be a native javascript support at this age of the web. What do you think guys, isn't the web mature enought to get a decent upload / download progress functions? What are big guys doing, youtube, google, flickr? |