JavaScript - Include() That Has Javascript
Greetings!
I included this script in my php mysql query result. test.php Code: <html> <head> <title></title> <script type = 'text/javascript'> function addRow() { tabBody=document.getElementById("inputtable"); row=document.createElement("TR"); cell1 = document.createElement("TD"); cell2 = document.createElement("TD"); cell3 = document.createElement("TD"); cell4 = document.createElement("TD"); cell5 = document.createElement("TD"); cell6 = document.createElement("TD"); textnode1=document.createElement("input"); textnode1.name="accnum[]"; textnode1.type="text"; textnode2=document.createElement("input"); textnode2.name="copy[]"; textnode2.type="text"; textnode3=document.createElement("input"); textnode3.name="locate[]"; textnode3.type="text"; textnode4=document.createElement("input"); textnode4.name="funds[]"; textnode4.type="text"; textnode5=document.createElement("input"); textnode5.name="stat[]"; textnode5.type="text"; textnode6=document.createElement("input"); textnode6.name="remarks[]"; textnode6.type="text"; cell1.appendChild(textnode1); cell1.appendChild(textnode2); cell1.appendChild(textnode3); cell1.appendChild(textnode4); cell1.appendChild(textnode5); cell1.appendChild(textnode6); row.appendChild(cell1); row.appendChild(cell2); row.appendChild(cell3); row.appendChild(cell4); row.appendChild(cell5); row.appendChild(cell6); tabBody.appendChild(row); } </script> </head> <body> <form> <table> <tbody id="inputtable"> <tr><td> <input type = 'text' name = 'accnum[]' placeholder = 'Accession number' /> <input type = 'text' name = 'copy[]' placeholder = 'Copies' /> <input type = 'text' name = 'locate[]' placeholder = 'Book Location' /> <input type = 'text' name = 'funds[]' placeholder = 'Source fund' /> <input type = 'text' name = 'stat[]' placeholder = 'Status' /> <input type = 'text' name = 'remarks[]' placeholder = 'Remarks' /> </tbody> </table> <br/> <input type="button" value="Add new" onclick="addRow();" /></td></tr> <br/><br/> <input type = 'submit' name='submit' value = 'Submit'/> </form> </body> </html> PHP Code: $query2 = mysql_query("SELECT * FROM tbl_bacquisition WHERE bd_Id = '$bdID'") or die (mysql_error()); while ($row2 = mysql_fetch_assoc($query2)) { echo $row2['ba_Accnum'].' '.$row2['ba_Copynum'].' '.$row2['ba_Section'].' '.$row2['ba_Sfunds'].' '.$row2['ba_Status'].' '.$row2['ba_Remarks'].'<br/>'; } } echo '<br/>'; include 'test.php'; My problem is that my script is not performing its job, it adds row when the button is clicked. But when I tried to other page, it works. Any help would be so much appreciated. Similar TutorialsI've now go to the point of wanting to include one javascript file within another. I was hoping for something analagous to: PHP Code: include("myfile.php"); But there isn't any built-in way of doing that?! I can see that it would be a security issue if you could include JS from anywhere - but surely it wouldn't be a problem if you could only include scripts on the same host as the including script? So, I have a dynamic PHP file on my server. I want to make it so browsers can take the code I provide and paste it in an .html, .php, or .asp file, and it'll display across the board. The file would need to be included, unless someone thinks there's a better way of doing this? The only example I could think of would be Google Adsense's code? But I'm not sure. Is it possible to use Javascript to dynamically change the PHP file used for an include? For example, if I have a php doc like Code: <html> <body> <div>other stuff</div> <div> <?php include('onefile.php'); ?> </div> <div>more other stuff</div> </body> </html> I can get Javascript to remove the included stuff, but I can't figure out how to change the <?php include('onefile.php'); ?> into <?php include('otherfile.php'); ?>. What would be the best way to do that? I included a js file into my html file. Everything work well in firefox but intenet explorer does not display my js file content. please helppp Js file // JavaScript Document document.write(<div class="RightSideGallerybox"> <div class="RightBoxContext">News</div> <div class="RightBoxPictures"><img src="../image/BotanicalTreeDecoration.jpg" /></div> <div class="RightBoxPictures"><img src="../image/IMG_3304.JPG" /></div> <div class="RightBoxPictures"><img src="../image/IMG_0297.JPG" width="150" height="100" /></div> <div class="ImportantRemarks">High School Admissions</div> <div class="ListOfRemarks"> <ul> <li>A. Phillip Randolph HS</li> <li>Astor Collegiate</li> <li>Aviation High School</li> <li>Bard College HS</li> <li>Bayside High School</li> </ul> </div> </div>); html file <div class="RightSideWrap"> <div class="footertext"> <script type="text/javascript" src="gallery.js"></script> </div> <!-------------------------------middle parts - right side--------------------------> </div> </div> Does anyone know how to accomplish this? I got the html file to show but none of the text in the file will show.
Hi guys, I've found tooltip I want to include in one of pages, and I'd appreciate your help. http://code.drewwilson.com/entry/tiptip-jquery-plugin I'm having troubles in finding a way to display it. Here is how I made it on this demo page : http://www.air.vlexo.net/tiptip/ I'm not sure what I did wrong, so please help me figure it out. Thanks in avance. Hi all. The below script is from suckerfish. Can anyone help me include a 'one sec delay' to keep the menu open onmouseout. First menu often closes too fast before I get a chance to move onto submenu. I've tried everything with setTimeout BUT I just can't get it right. Nothing I do works. Can somebody PLEASE show me so I can kick myself. LT Code: <script type="text/javascript"><!--//--><![CDATA[//><!-- sfHover = function() { var sfEls = document.getElementById("nav").getElementsByTagName("LI"); for (var i=0; i<sfEls.length; i++) { sfEls[i].onmouseover=function() { this.className+=" sfhover"; } sfEls[i].onmouseout=function(){ this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); } } } if (window.attachEvent) window.attachEvent("onload", sfHover); //--><!]]></script> Hi I am in the middle of building some API's for my site and have built a cernal for all API's to read but i dont want the user to add two script tags to their sites code so I was wondering how I could do this. These are not my real files but will give you the full view of what it is I am trying to do. - cernal.js Code: var error = function(o) { if(o !== '') { alert(o); } }; - pub109283746374.js Code: // include the cernal.js file here somehow // Do a small function that uses the error cernal function function ShowNotice() { if(API_KEY !== '' && API_KEY !== undefined) { alert('Success'); } else { error('Sorry but you have an invalid API key.'); } } - http://www.userswebsite.com/demoFile.html Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>WHOISearch API Demo</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="http://www.mysite.com/API/pub109283746374.js"></script> </head> <body> <script type="text/javascript"> //<![CDATA[ ShowNotice(); // Alerts 'Sorry but you have an invalid API key.' //]]> </script> <script type="text/javascript"> //<![CDATA[ API_KEY = 'pub109283746374'; ShowNotice(); // Alerts 'Success' //]]> </script> </body> </html> If anyone can help me it will help me so much with finishing these API's, please reply if you know how I can do this, Thank You. DJCMBear Ok I want to be able to include a html file into my template. I want the php include to work when I press a button that will put the include into a specific element with the document.getElementById("").innerHTML method in javascript. I want the include to be able to be more then a single line. For example I want to be able to write my code like this <div> some text </div> and not have to write it like this <div>some test</div> Thanks Shelby Hi all, I cant get this code to work because I do not know how to include the % character. Any help would be appreciated. My line break isnt working either Cheers, Adrian Code: rightButton.innerHTML = (rightOutcome1Prob+" chance of "+rightOutcome1+"\r\n else "+rightOutcome2); Greetings! I have this script and I want to take out the part below the /////////////////////////// up to the buildMenu(); statement. I would dynamically create the menu list with php. Problem is I don't know javascript that well This is its own .js file not a script within the head section of the page. Code: <!-- /* Configure menu styles below NOTE: To edit the link colors, go to the STYLE tags and edit the ssm2Items colors */ YOffset=150; // no quotes!! XOffset=0; staticYOffset=30; // no quotes!! slideSpeed=20 // no quotes!! waitTime=100; // no quotes!! this sets the time the menu stays out for after the mouse goes off it. menuBGColor="black"; menuIsStatic="yes"; //this sets whether menu should stay static on the screen menuWidth=150; // Must be a multiple of 10! no quotes!! menuCols=2; hdrFontFamily="verdana"; hdrFontSize="2"; hdrFontColor="white"; hdrBGColor="#170088"; hdrAlign="left"; hdrVAlign="center"; hdrHeight="15"; linkFontFamily="Verdana"; linkFontSize="2"; linkBGColor="white"; linkOverBGColor="#FFFF99"; linkTarget="_top"; linkAlign="Left"; barBGColor="#444444"; barFontFamily="Verdana"; barFontSize="2"; barFontColor="white"; barVAlign="center"; barWidth=20; // no quotes!! barText="SIDE MENU"; // <IMG> tag supported. Put exact html for an image to show. /////////////////////////// // ssmItems[...]=[name, link, target, colspan, endrow?] - leave 'link' and 'target' blank to make a header ssmItems[0]=["Menu"] //create header ssmItems[1]=["Dynamic Drive", "http://www.dynamicdrive.com", ""] ssmItems[2]=["What's New", "http://www.dynamicdrive.com/new.htm",""] ssmItems[3]=["What's Hot", "http://www.dynamicdrive.com/hot.htm", ""] ssmItems[4]=["Message Forum", "http://www.codingforums.com", "_new"] ssmItems[5]=["Submit Script", "http://www.dynamicdrive.com/submitscript.htm", ""] ssmItems[6]=["Link to Us", "http://www.dynamicdrive.com/link.htm", ""] ssmItems[7]=["FAQ", "http://www.dynamicdrive.com/faqs.htm", "", 1, "no"] //create two column row ssmItems[8]=["Email", "http://www.dynamicdrive.com/contact.htm", "",1] ssmItems[9]=["External Links", "", ""] //create header ssmItems[10]=["JavaScript Kit", "http://www.javascriptkit.com", ""] ssmItems[11]=["Freewarejava", "http://www.freewarejava.com", ""] ssmItems[12]=["Coding Forums", "http://www.codingforums.com", ""] buildMenu(); //--> I don't know the syntax to do something like this: Code: <!-- /* Configure menu styles below NOTE: To edit the link colors, go to the STYLE tags and edit the ssm2Items colors */ YOffset=150; // no quotes!! XOffset=0; staticYOffset=30; // no quotes!! slideSpeed=20 // no quotes!! waitTime=100; // no quotes!! this sets the time the menu stays out for after the mouse goes off it. menuBGColor="black"; menuIsStatic="yes"; //this sets whether menu should stay static on the screen menuWidth=150; // Must be a multiple of 10! no quotes!! menuCols=2; hdrFontFamily="verdana"; hdrFontSize="2"; hdrFontColor="white"; hdrBGColor="#170088"; hdrAlign="left"; hdrVAlign="center"; hdrHeight="15"; linkFontFamily="Verdana"; linkFontSize="2"; linkBGColor="white"; linkOverBGColor="#FFFF99"; linkTarget="_top"; linkAlign="Left"; barBGColor="#444444"; barFontFamily="Verdana"; barFontSize="2"; barFontColor="white"; barVAlign="center"; barWidth=20; // no quotes!! barText="SIDE MENU"; // <IMG> tag supported. Put exact html for an image to show. /////////////////////////// // ssmItems[...]=[name, link, target, colspan, endrow?] - leave 'link' and 'target' blank to make a header include menu-file buildMenu(); //--> Not really sure how to go about this Thanks for any help in advance! I have some javascript code that hides and unhides a menu when a link is clicked, and that is working just fine. What I also need the function to do is switch the CSS class of change_this in the code below to change_that when the link is clicked, and then switch it back to change_this when the link is clicked again. Can someone assist me? I have tried integrating/modifying other scripts I found with this one, but nothing has worked for me. It seems so simple, but I just cant get this thing working. Thanks to anyone who replies with help! Code: <script type="text/javascript"> function HideandUNhideObj(ThisObj){ nav=document.getElementById(ThisObj).style if(nav.display=="none"){ nav.display='block'; }else{ nav.display='none'; } } </script> Code: <li class="change_this"><a id="nav" href="javascript: void();" onclick="HideandUNhideObj('display');"></a> <ul id="display" style="display: none;"> <div id="container_div">stuff</div> So if both validations work seperatley (if I just put radio buttons validation in the function without the spinner validation then radio buttons validation works and same vise versa), how come when I put both validations in the function, the top validation which is the radio validation works but the bottom validation which is the spinner validation does not display a message when it is suppose to? Code is below: Code: <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>Create a Session</title> <script type="text/javascript"> function validation() { var errMsgO = document.getElementById("radioAlert"); var btnRadioO = document.getElementsByName("sessionNo"); var isbtnRadioChecked = false; var errQuesMsgO = document.getElementById("numberAlert"); var questionNumberO = document.getElementsByName("txtQuestion"); for(i=0; i < btnRadioO.length; i++){ if(btnRadioO[i].checked){ isbtnRadioChecked = true; } } if(!isbtnRadioChecked) { errMsgO.innerHTML = "Please Select the Number of Sessions you Require"; } else { errMsgO.innerHTML = ""; } return false; if(questionNumberO[0].value == 0){ errQuesMsgO.innerHTML = "Please Set the Number of Questions"; } else { errQuesMsgO.innerHTML = ""; } return false; } </script> </head> <body> <form action="create_session.php" method="post" name="sessionform"> <table> <tr> <th>2: Number of Sessions :</th> <td class="sessionNo"><input type="radio" name="sessionNo" value="1" />1</td> <td class="sessionNo"><input type="radio" name="sessionNo" value="2" />2</td> <td class="sessionNo"><input type="radio" name="sessionNo" value="3" />3</td> <td class="sessionNo"><input type="radio" name="sessionNo" value="4" />4</td> <td class="sessionNo"><input type="radio" name="sessionNo" value="5" />5</td> </tr> </table> <div id="radioAlert"></div> <table> <tr> <th>Number of Questions:</th> <td class="spinner"><textarea class="spinnerQuestion" name="txtQuestion" id="txtQuestion" cols="2" rows="1"></textarea></td> <td><button class="scrollBtn" id="btnQuestionUp"><img src="Images/black_uppointing_triangle.png" alt="Increase" /></button> <button class="scrollBtn" id="btnQuestionDown"><img src="Images/black_downpointing_triangle.png" alt="Decrease" /></button></td> </tr> </table> <div id="numberAlert"></div> <p><input class="questionBtn" type="button" value="Prepare Questions" name="prequestion" onClick="validation()" /></p> <!-- Prepare Questions here--> </form> </body> Hi! how do I include .html files inside a document.write()? Like document.write('include top.html' "hello!" 'include bottom.html') or something. I searched for it, and found this: <!--#include file="top.html" --> But it doesn't work for me. What is wrong? I would be very happy if someone could help me Hello! I am trying to find a script that allows you to open multiple browser tabs and then close each of those tabs, either one by one or all at once. Does anyone know how to do this please? Thanks so much for your help. I want to have another go at Javascript. I have several books on the subject but I find that my eyesight is a major problem. Therefore I want to try an on-line solution, preferably free. I have Googled, but there are so many that I am almost dizzy with the choices. Perhaps someone could recommend one. Not too fussy visually. My knowledge is VERY basic. Frank Does anyone know how to make URL links that use Javascript still work when users have Javascript disabled on their browser? The only reason I'm using JS on a URL is because my link opens a PDF file, and I'm forcing it not to cache so users have the latest version. I tried the <script><noscript> tags, but I'm not sure if I'm using it correctly, as my URL completely disappears. Below is my HTML/Javascript code: <p class="download"> <script type="text/javascript">document.write("<span style=\"text-decoration: underline;\"><a href=\"javascript:void(0);\" onclick=\"window.open( 'http://www.webchild.com.au/mediakit/Direct_Media_Kit_Web.pdf?nocache='+ Math.floor( Math.random()*11 ) );\" >The Child Magazines Media Kit</a></span> (PDF 1 MB) ");</script> <noscript><span style="text-decoration: underline;"><a href="http://www.webchild.com.au/mediakit/Direct_Media_Kit_Web.pdf" >The Child Magazines Media Kit</a></span> (PDF 1 MB)</noscript> </p> Thanks for any help, Michael Hi, I have the following code snippet: test.html ====== <script language="javascript" type="text/javascript"> var testVariable = "test"; </script> <script language="javascript" type="text/javascript" src="test.js"> </script> test.js ===== var testVariable = window.top.testVariable; In firefox, I'm able to access testvariable defined within test.html in test.js. But in chrome, test.js couldnot get the window.top.testVariable field defined in test.html. Can any one please let me know how i can make it work in chrome?. Am i missing something here?. Hi Guys, I am new at JavaScript and start to do some tutorials.What I am trying to do here is prompting user to input a name and if the name was valid the page(document) will display with all objects like the button.But if user enter a wrong name then the button will be disabled! I create the following code but it did not work <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>New Web Project</title> <script language="JavaScript" type=""> function changeColor(){ document.bgColor = "Gray"; } </script> </head> <body> <script language="JavaScript" type="text/javascript"> var person = ""; person = prompt('What is Your Name:'); if (person == "Foo") { document.write("<h1 />Welcome " + person); document.bgColor = "Yellow"; } else { document.write("<h1 />Access Denied!!!!"); document.bgColor = "Red"; document.getElementById("gree").disabled = true; } </script> <div> <p/><input id="gree" type="button" value="Gray " onClick="changeColor();"> </div> </body> </html> as you can see I used the: document.getElementById("gree").disabled = true; but it did not work , could you please give an idea how I can solve this problem? Thanks |