JavaScript - Javascript Revealing Answers Script Help
Hi I'm Terbinafine
I do online school, and it utilizies a popular, virtual education system known as "OdysseyWare". I found a javascript 'cheat' per se, online, which is supposed to reveal the answers to your questions. Here's an example of the source code for a multiple choice question: Code: [EDIT] OdysseyWare Code removed. The code that was removed was a very small javascript piece of code, totaling less than 70 lines. The javascript that was removed here could be recreated by an individual inside of a day, or even 30 minutes or less. It is the Editor’s opinion that, given the ease with which one is able to, apparently, find the answers to the OdysseyWare testing software, the OdysseyWare software is not fit for educational use. What good is testing software that, apparently, allows the user to be able to find all of the answers to the questions by using simple code that they can find on the internet or make themselves? As an educator for many years, I would NOT and will NEVER use this software and cannot recommend that anyone else use it. Similar TutorialsHi all, I was just wondering if there is a JavaScript tutorial online that shows you how to do similar hover effect to what Twitter does with the trending topics. Such as Inception. When you hover over it and a black bubble appears. Also I'm not sure what it is called. If anyone knows how to do it, It would be appreciated. Thanks! I am using a content revealing script, it is functioning pefectly except for one small issue. I have the content being shown on mouseover, but I would not like it to display right away - i need a delay on the mouseover. meaning that only if mouseover for a set time (say 3000ms.) it will show. the purpose of this is to not accidently open the content when travelling with the mouse around the page.. the content will show ONLY if the user wants it to open it ie. holding the mouse on there for a few seconds. The script I am using is from featured content slider. contentslider.js I marked areas of interest in the code in RED Code: //** Featured Content Slider script- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com. //** May 2nd, 08'- Script rewritten and updated to 2.0. //** June 12th, 08'- Script updated to v 2.3, which adds the following features: //1) Changed behavior of script to actually collapse the previous content when the active one is shown, instead of just tucking it underneath the later. //2) Added setting to reveal a content either via "click" or "mouseover" of pagination links (default is former). //3) Added public function for jumping to a particular slide within a Featured Content instance using an arbitrary link, for example. //** July 11th, 08'- Script updated to v 2.4: //1) Added ability to select a particular slide when the page first loads using a URL parameter (ie: mypage.htm?myslider=4 to select 4th slide in "myslider") //2) Fixed bug where the first slide disappears when the mouse clicks or mouses over it when page first loads. //** Dec 20th, 12'- v 2.41: Fixed bug with slider failing to load if the same script is used on different pages with different # of contents var featuredcontentslider={ //3 variables below you can customize if desired: ajaxloadingmsg: '<div style="margin: 20px 0 0 20px"><img src="loading.gif" /> Fetching slider Contents. Please wait...</div>', bustajaxcache: true, //bust caching of external ajax page after 1st request? enablepersist: true, //persist to last content viewed when returning to page? settingcaches: {}, //object to cache "setting" object of each script instance jumpTo:function(fcsid, pagenumber){ //public function to go to a slide manually. this.turnpage(this.settingcaches[fcsid], pagenumber) }, ajaxconnect:function(setting){ var page_request = false if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken) try { page_request = new ActiveXObject("Msxml2.XMLHTTP") } catch (e){ try{ page_request = new ActiveXObject("Microsoft.XMLHTTP") } catch (e){} } } else if (window.XMLHttpRequest) // if Mozilla, Safari etc page_request = new XMLHttpRequest() else return false var pageurl=setting.contentsource[1] page_request.onreadystatechange=function(){ featuredcontentslider.ajaxpopulate(page_request, setting) } document.getElementById(setting.id).innerHTML=this.ajaxloadingmsg var bustcache=(!this.bustajaxcache)? "" : (pageurl.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime() page_request.open('GET', pageurl+bustcache, true) page_request.send(null) }, ajaxpopulate:function(page_request, setting){ if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){ document.getElementById(setting.id).innerHTML=page_request.responseText this.buildpaginate(setting) } }, buildcontentdivs:function(setting){ var alldivs=document.getElementById(setting.id).getElementsByTagName("div") for (var i=0; i<alldivs.length; i++){ if (this.css(alldivs[i], "contentdiv", "check")){ //check for DIVs with class "contentdiv" setting.contentdivs.push(alldivs[i]) alldivs[i].style.display="none" //collapse all content DIVs to begin with } } if (setting.currentpage > setting.contentdivs.length){ setting.currentpage=1 setting.prevpage=1 } }, buildpaginate:function(setting){ this.buildcontentdivs(setting) var sliderdiv=document.getElementById(setting.id) var pdiv=document.getElementById("paginate-"+setting.id) var phtml="" var toc=setting.toc var nextprev=setting.nextprev if (typeof toc=="string" && toc!="markup" || typeof toc=="object"){ for (var i=1; i<=setting.contentdivs.length; i++){ phtml+='<a href="#'+i+'" class="toc">'+(typeof toc=="string"? toc.replace(/#increment/, i) : toc[i-1])+'</a> ' } phtml=(nextprev[0]!=''? '<a href="#prev" class="prev">'+nextprev[0]+'</a> ' : '') + phtml + (nextprev[1]!=''? '<a href="#next" class="next">'+nextprev[1]+'</a>' : '') pdiv.innerHTML=phtml } var pdivlinks=pdiv.getElementsByTagName("a") var toclinkscount=0 //var to keep track of actual # of toc links for (var i=0; i<pdivlinks.length; i++){ if (this.css(pdivlinks[i], "toc", "check")){ if (toclinkscount>setting.contentdivs.length-1){ //if this toc link is out of range (user defined more toc links then there are contents) pdivlinks[i].style.display="none" //hide this toc link continue } pdivlinks[i].setAttribute("rel", ++toclinkscount) //store page number inside toc link pdivlinks[i][setting.revealtype]=function(){ featuredcontentslider.turnpage(setting, this.getAttribute("rel")) return false } setting.toclinks.push(pdivlinks[i]) } else if (this.css(pdivlinks[i], "prev", "check") || this.css(pdivlinks[i], "next", "check")){ //check for links with class "prev" or "next" pdivlinks[i].onclick=function(){ featuredcontentslider.turnpage(setting, this.className) return false } } } this.turnpage(setting, setting.currentpage, true) if (setting.autorotate[0]){ //if auto rotate enabled pdiv[setting.revealtype]=function(){ featuredcontentslider.cleartimer(setting, window["fcsautorun"+setting.id]) } sliderdiv["onclick"]=function(){ //stop content slider when slides themselves are clicked on featuredcontentslider.cleartimer(setting, window["fcsautorun"+setting.id]) } setting.autorotate[1]=setting.autorotate[1]+(1/setting.enablefade[1]*50) //add time to run fade animation (roughly) to delay between rotation this.autorotate(setting) } }, urlparamselect:function(fcsid){ var result=window.location.search.match(new RegExp(fcsid+"=(\\d+)", "i")) //check for "?featuredcontentsliderid=2" in URL return (result==null)? null : parseInt(RegExp.$1) //returns null or index, where index (int) is the selected tab's index }, turnpage:function(setting, thepage, autocall){ var currentpage=setting.currentpage //current page # before change var totalpages=setting.contentdivs.length var turntopage=(/prev/i.test(thepage))? currentpage-1 : (/next/i.test(thepage))? currentpage+1 : parseInt(thepage) turntopage=(turntopage<1)? totalpages : (turntopage>totalpages)? 1 : turntopage //test for out of bound and adjust if (turntopage==setting.currentpage && typeof autocall=="undefined") //if a pagination link is clicked on repeatedly return setting.currentpage=turntopage setting.contentdivs[turntopage-1].style.zIndex=++setting.topzindex this.cleartimer(setting, window["fcsfade"+setting.id]) setting.cacheprevpage=setting.prevpage if (setting.enablefade[0]==true){ setting.curopacity=0 this.fadeup(setting) } if (setting.enablefade[0]==false){ //if fade is disabled, fire onChange event immediately (verus after fade is complete) setting.contentdivs[setting.prevpage-1].style.display="none" //collapse last content div shown (it was set to "block") setting.onChange(setting.prevpage, setting.currentpage) } setting.contentdivs[turntopage-1].style.visibility="visible" setting.contentdivs[turntopage-1].style.display="block" if (setting.prevpage<=setting.toclinks.length) //make sure pagination link exists (may not if manually defined via "markup", and user omitted) this.css(setting.toclinks[setting.prevpage-1], "selected", "remove") if (turntopage<=setting.toclinks.length) //make sure pagination link exists (may not if manually defined via "markup", and user omitted) this.css(setting.toclinks[turntopage-1], "selected", "add") setting.prevpage=turntopage if (this.enablepersist) this.setCookie("fcspersist"+setting.id, turntopage) }, setopacity:function(setting, value){ //Sets the opacity of targetobject based on the passed in value setting (0 to 1 and in between) var targetobject=setting.contentdivs[setting.currentpage-1] if (targetobject.filters && targetobject.filters[0]){ //IE syntax if (typeof targetobject.filters[0].opacity=="number") //IE6 targetobject.filters[0].opacity=value*100 else //IE 5.5 targetobject.style.filter="alpha(opacity="+value*100+")" } else if (typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax targetobject.style.MozOpacity=value else if (typeof targetobject.style.opacity!="undefined") //Standard opacity syntax targetobject.style.opacity=value setting.curopacity=value }, fadeup:function(setting){ if (setting.curopacity<1){ this.setopacity(setting, setting.curopacity+setting.enablefade[1]) window["fcsfade"+setting.id]=setTimeout(function(){featuredcontentslider.fadeup(setting)}, 50) } else{ //when fade is complete if (setting.cacheprevpage!=setting.currentpage) //if previous content isn't the same as the current shown div (happens the first time the page loads/ script is run) setting.contentdivs[setting.cacheprevpage-1].style.display="none" //collapse last content div shown (it was set to "block") setting.onChange(setting.cacheprevpage, setting.currentpage) } }, cleartimer:function(setting, timervar){ if (typeof timervar!="undefined"){ clearTimeout(timervar) clearInterval(timervar) if (setting.cacheprevpage!=setting.currentpage){ //if previous content isn't the same as the current shown div setting.contentdivs[setting.cacheprevpage-1].style.display="none" } } }, css:function(el, targetclass, action){ var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig") if (action=="check") return needle.test(el.className) else if (action=="remove") el.className=el.className.replace(needle, "") else if (action=="add") el.className+=" "+targetclass }, autorotate:function(setting){ window["fcsautorun"+setting.id]=setInterval(function(){featuredcontentslider.turnpage(setting, "next")}, setting.autorotate[1]) }, getCookie:function(Name){ var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair if (document.cookie.match(re)) //if cookie found return document.cookie.match(re)[0].split("=")[1] //return its value return null }, setCookie:function(name, value){ document.cookie = name+"="+value }, init:function(setting){ var persistedpage=this.getCookie("fcspersist"+setting.id) || 1 var urlselectedpage=this.urlparamselect(setting.id) //returns null or index from: mypage.htm?featuredcontentsliderid=index this.settingcaches[setting.id]=setting //cache "setting" object setting.contentdivs=[] setting.toclinks=[] setting.topzindex=0 setting.currentpage=urlselectedpage || ((this.enablepersist)? persistedpage : 1) setting.prevpage=setting.currentpage setting.revealtype="on"+(setting.revealtype || "click") setting.curopacity=0 setting.onChange=setting.onChange || function(){} if (setting.contentsource[0]=="inline") this.buildpaginate(setting) if (setting.contentsource[0]=="ajax") this.ajaxconnect(setting) } } This is the code you embed in the webpage: Code: <h2>Example 1</h2> <!--Inner content DIVs should always carry "contentdiv" CSS class--> <!--Pagination DIV should always carry "paginate-SLIDERID" CSS class--> <div id="slider1" class="sliderwrapper"> <div class="contentdiv"> Content 1 Here. <br /> <p></p><a href="javascript:featuredcontentslider.jumpTo('slider1', 3)">Go to 3rd slide</a></p> </div> <div class="contentdiv"> Content 2 Here. </div> <div class="contentdiv"> Content 3 Here. </div> </div> <div id="paginate-slider1" class="pagination"> </div> <script type="text/javascript"> featuredcontentslider.init({ id: "slider1", //id of main slider DIV contentsource: ["inline", ""], //Valid values: ["inline", ""] or ["ajax", "path_to_file"] toc: "#increment", //Valid values: "#increment", "markup", ["label1", "label2", etc] nextprev: ["Previous", "Next"], //labels for "prev" and "next" links. Set to "" to hide. revealtype: "mouseover", //Behavior of pagination links to reveal the slides: "click" or "mouseover" enablefade: [true, 0.2], //[true/false, fadedegree] autorotate: [false, 3000], //[true/false, pausetime] onChange: function(previndex, curindex){ //event handler fired whenever script changes slide //previndex holds index of last slide viewed b4 current (1=1st slide, 2nd=2nd etc) //curindex holds index of currently shown slide (1=1st slide, 2nd=2nd etc) } }) </script> My code goes through the answer function (below) and it determins if you answered green. If you answered green a popup says correct other wise incorrect. How can I modify my code so that I can add multiple answers for different questions.Example q1 answer = green q2 answer = blue . . q20 answer = Friday Here is my .js code Code: var n = 16; // modify this for number of seconds to answer document.getElementById( 'time').value = "Answer in " + n + " seconds"; var i = setInterval('count()' , 1000); var tooLate; function count() { tooLate = 0; n--; if(n >=0) { document.getElementById( 'time').value = "Answer in " + n + " seconds"; } else { clearInterval(i); alert("Too late!"); if(document.getElementById( 'answer').value == correct){ tooLate = 1; } } function answer() { var correct = "green"; // This is the correct answer if (tooLate == 0) { if(document.getElementById( 'answer').value == correct) { clearInterval(i); alert("Right Answer with " + n + " seconds remaining"); } else{ clearInterval(i); alert("Incorrect! The answer was " + correct); } } submitform(); //submit form function submitform() { document.forms["myform"].submit(); } } My code goes through the answer function (below) and it determines if you answered green. If you answered green a popup says correct other wise incorrect. How can I modify my code so that I can add multiple answers for different questions.Example q1.html what color is the grass? q2.htm what color is the sky? . . q20.html what day of the week was the last baseball game? _____________________________________________________ now in my javascript every question is going to go through the answer function and think the answer is green. that would be correct for q1.html but what if i am on q20.html and it goes through the answer function. It will think the answer is green. So how can i change the code so q1.html knows that the answer is green. q2.html knows the answer is blue? here is my code Code: var n = 16; // modify this for number of seconds to answer document.getElementById( 'time').value = "Answer in " + n + " seconds"; var i = setInterval('count()' , 1000); var tooLate; function count() { tooLate = 0; n--; if(n >=0) { document.getElementById( 'time').value = "Answer in " + n + " seconds"; } else { clearInterval(i); alert("Too late!"); document.getElementById('answer').value = ""; tooLate = 1; } } function answer() { var correct = "green"; // This is the correct answer if (tooLate == 0) { if(document.getElementById( 'answer').value == correct) { clearInterval(i); alert("Right Answer with " + n + " seconds remaining"); } else{ clearInterval(i); alert("Incorrect! The answer was " + correct); } } submitform(); //submit form function submitform() { document.forms["myform"].submit(); } } Thank you! Hi, I'm looking for a javascript/css code that can do the following, for a click button: - When mouse is not over the click-button, a text should be displayed at the right of the button, in a bordered textbox - 85% transparency (hardly visible) (- when mouse hovers over the button, the button image changes to a different one <- I know how to do this) - When the button is clicked the text shows up normaly (0% transparency) - When clicking again the button OR anywhere else on the page, the text goes back to 85% transparency. If have any ideas where I could find such a code please let me know. Thanks. I am having trouble with the following code. Right now the user clicks the button and it shows all of the blogs from the blog array. However I want it to just reveal 2 then two more and two more and so on as the user clicks button. I have tried multiple things but can't seem to get it right. Most of the things i try either reveal the entire blog on start or when the user clicks hides all of them. Code: function showBlog(numEntries) { // Show the list of blog entries blog.sort(Blog.blogSorter); // First sort the blog if (!numEntries) // Adjust the number of entries to show the full blog, if necessary function showBlog(numEntries) { // Show the list of blog entries blog.sort(Blog.blogSorter); // First sort the blog if (!numEntries) // Adjust the number of entries to show the full blog, if necessary numEntries = blog.length; // Show the blog entries var blogListHTML = ""; for (var i = 0; i < blog.length && i < numEntries; i++ ) { blogListHTML += blog[i].toHTML(i % 2 == 0); } document.getElementById("blog").innerHTML = blogListHTML; // Set the blog HTML code on the page } // Show the blog entries var blogListHTML = ""; for (var i = 0; i < blog.length && i < numEntries; i++ ) { blogListHTML += blog[i].toHTML(i % 2 == 0); } document.getElementById("blog").innerHTML = blogListHTML; // Set the blog HTML code on the page } Hi all, Only recently started, self-teaching, html and Java in order to get a project idea of mine up and running. First barrier I've come across is trying to sort out a drop down with search button that will then reveal the connected hidden div, I've mangled together some code from a couple of sources with what I've learnt, but not really sure how to tie in the "Search" button to the showDiv(divname) function. Wondering if anyone could help out. Many thanks in advance Code: <head> <title>Untitled</title> <link rel="stylesheet" type="text/css" href="stylesheet.css" /> <script type="text/javascript"><!-- var lastDiv = ""; function showDiv(divname) { if (lastDiv) { document.getElementById(lastDiv).className = "hiddenDiv"; } if (divName && document.getElementById(divName)) { document.getElementById(divName).className = "visibleDiv"; lastDiv = divName; } } </script> </head> <body> <h1> <form name="form" > <select name="select"> <option selected>Choose <option value="one"> one <option value="two"> two <option value="other"> other </select> <input type="button" value="Search" onClick="showDiv(this.value)"> </form> </h1></br> <h2> Results: <p id="one" class="hiddenDiv">one</p> <p id="two" class="hiddenDiv">two</p> <p id="other" class="hiddenDiv">other</p> </h2> </body> </html> From my stylesheet: Code: .hiddenDiv { display: none; } .visibleDiv { display: block; } Hi everyone-- I am a fourth grade teacher and I have an idea for a program I could use with my students. I think (key word, I don't know anything about programming) that it should be relatively simple to do. A short description of what the program would do will follow, but my posting is for three main reasons: 1) Is this possible? (I assume it is) 2) As I would be willing to pay for this (up to a certain amount), how much might it cost me if I hired a freelance programmer? 3) Is there anyone out there who would be able to help me with this? Okay, as for the program: it would be a program that would make your own "Jack Attack" (like from the computer game "You Don't Know Jack"). It would give you a place to input up to 10 to 15 keywords (or vocabulary definitions) for the middle and keywords (or vocab words) that would fly past. It would respond to some sort of button input (I'm thinking space bar)....and have an action for wrong answers (buzzer sound) and an action for a right answer (ding! and then move on to next question). Maybe after the game it would give a readout of how many right out of how many possible. It would be really cool to be able to have some background music, maybe manipulate the the colors, fonts, etc. I am wanting to leave the program kind of generic so that I could use this for all sorts of applications: use it for vocabulary words in different subjects, match authors with books, "just for fun" games, maybe even use it for some math facts. Any information you would have is more than appreciated! Thanks for helping a teacher out! Clay im having issue with fetching answers from database by json file it says error once i click finish button, what do you think the error could be? here is the responses.php file code: and here is the js code that pulls answers Code: $.ajax({ url :'reponses.php', type : 'POST', data : 'fetchAnswers=' + answerCode + '&id_examens=' + examensId, dataType : 'json', success : function(data){ $(lastButton).html('Finish'); answers =data;// $.parseJSON(data); $(dataDiv).data('answer', answers); callback(answers); }, error : function(resultat, statut, erreur){ $(lastButton).html('Finish'); alert('There was a problem with your network connection. Please click "Finish" again to re-try. If the problem persists, you will have to wait until network connectivity has been restored.'); }, complete : function(resultat, statut){ } }); } else { answers = $(dataDiv).data('answer'); $(lastButton).html('Finish'); callback(answers); } } } when i click the finish button it shows the alert message instead of bring answer and proceed Reply With Quote 01-17-2015, 06:18 PM #2 yamizer View Profile View Forum Posts New to the CF scene Join Date Jan 2015 Posts 2 Thanks 0 Thanked 0 Times in 0 Posts sorry i forgot to add responses.php file codee Code: <?php include("config.php"); header('Content-Type: application/json'); $answers=array(); $sql_questions = 'SELECT * FROM question '; $res_questions = mysql_query($sql_questions); while($data_questions=mysql_fetch_array($res_questions)){ $id_question=$data_questions["id"]; //$sql_answers = "SELECT * FROM reponse WHERE id_question=".$id_question." AND rep_correcte='1'"; $sql_answers = "SELECT * FROM reponse WHERE id_question=".$id_question;//." AND rep_correcte='1'"; $res_answers = mysql_query($sql_answers); $i=1; while($data_answers=mysql_fetch_array($res_answers)){ if($data_answers["rep_correcte"]==1) { $answers[]=$i;//$data_answers['id']; } //$answers[]=$data_answer["rep_correcte"]; $i++; } }//["1","6"] // $answers=array(1,6); echo json_encode($answers); /* $answers=array(1,3,2,1,1,4,1); echo json_encode($answers); */ exit(); ?> Reply With Quote 01-19-2015, 05:44 AM #3 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,311 Thanks 82 Thanked 4,754 Times in 4,716 Posts That is TERRIBLE TERRIBLE PHP coding! (Well, actually SQL coding!) NEVER NEVER do a SELECT *inside* a PHP loop that results from a different SELECT!! But the PHP code makes no sense in any case. You are invoking that page from the JSON code with parameters: Code: 'fetchAnswers=' + answerCode + '&id_examens=' + examensId Yet NOWHERE in the PHP code are you USING those parameters! That is, you should be doing PHP Code: $answerCode = $_POST["answerCode"]; $id_examens = $_POST["id_examens"]; and then USING those values in your PHP code, probably to SELECT the correct records! Hi, I'm working on a simple website in which I'm required to use two types of forms input on a webpage. I have decided to make a simple quiz which will be designed as follows; -------------------------------------------------------- Q1: The largest mammal on land is: (radio button choices) Q2: Please tick the two correct answers: (tick boxes, four available... only two correct) ---------------------------------------------------------- (BUTTON: Please click here for the answers) ... answers should appear once the above button is pressed... Answers: Q1: B Q2: A * C Is this possible in a simple way? Sounds quite straight-forward but I'm no expert so forgive me.. Ps: Is it possible to design a radio button which, depending on the choice, the related-text will appear underneath on the same page? So if they select 'A' then paragraph 'A' will show, if they select 'C' then paragraph 'C' will appear (with the rest hiding)... Thanks 4 your time! If you type in a question in the question box and select your option and answers from the option and answers box ( do this: open grid, click on button "3", type in "1" in the "Number of Answers" text-box and select button "A" by clicking on it, the button should turn green) Now if you click on the "Add Question" button, it will display a new row in a table which would display the question in the textarea, but how do I code it so that it would display the buttons and the selected buttons under the "Answers" column? The code for inserting a row under the "Answer" column is below: Code: cell = document.createElement("td"); cell.className = "answer"; input = document.createElement("input"); input.name = "answer_" + qnum; cell.appendChild(input); row.appendChild(cell); Whole code is in jsfiddle, click [here][1] [1]: http://jsfiddle.net/mMb8c/21/ Hi, I was wondering how to load an external .php script file in javascript, and make use of a php variable in the javascript. Thanks in advance. EDIT: If this is not possible, is there some way to send the php data to the javascript by using php, and then accessing the data that was sent in the javascript, and making use of it? What I'm trying to do is get a OpenTok session id from a .php script to javascript. Hello all, I'm new to PHP (and web development in general) and have come across something that to me seems really, really bizarre! Background I am currently designing and developing an online enrolment form for my employer, a training company. The form consists of 3 pages - pages 1 and 2 are for data input whilst page 3 is a summary page with only one input, a box to check that the customer agrees to our T&Cs. Page 3 also includes a box where calculations are made as to the price of the selected training course based on choices made earlier in the form. The form displayed on page 2, and some of the text on page 3, changes depending on a choice made on page one - that is, whether they are paying for the course themselves or their employer is funding it. If they choose employer, they get one form, if they choose self funding they get a different one. However, both of these forms are contained within a single .php file, using session variables to decide which one should be displayed. I am using sessions to transfer the data between the pages. Each page has been made sticky using session variables. Real-time validation is carried out using javascript on each individual page, then a final PHP validation check is run on the whole thing when the customer tries to submit the final page. Javascript is also used on page one to calculate the price of the course in real time so the customer can see how much he/she will be paying before proceeding further. The Problem I find this really strange: In Firefox, everything works perfectly In Internet Explorer, when JavaScript is turned off, everything is fine. But when JS is switched on, the PHP validation on the final page seems to go haywire, thus making it impossible to submit the form. In Chrome, again when JS is switched off, everything works, but when switched on, I can't even get past the first page. Instead of loading the correct form for page 2, I just get a blank screen. Can anyone help? This is my first major project and I've been working on it for weeks, coming up against all sorts of problems and tearing my hair out but managing to solve them. Now I'm completely stumped, when I'm almost within touching distance of completion!! I can't post the code here as it's 3 separate documents and very complicated, but if you want to have a look at the form itself go to: http://testing.xenongroupadmin.com/t.../enrolment.php I hope someone can help! Thanks very much! All the best Chris I embedded the following into my blog; Code: <br><script language="javascript" src="http://www.quotedb.com/quote/quote.php?action=random_quote&=&=&"></script> <br> It works fine, but I'm trying to find a way to refresh only the script on my blog, instead of having to reload the entire page. Coding a refresh button, for instance. How would I go about doing this? Thank you in advance. Hi, I have a little problem with placing a javascript into a php script If the action "Change" is true then I want to open a new window with a javascript below. I get an error message: Parse error: syntax error, unexpected '<' in /home/........ on line xx On that xx line starts the Javascript What must I do to solve this problem. <?php.................... if($_REQUEST['action']=="Change") { mysql_query("UPDATE Persons SET Itemstate = '{$_REQUEST['Nr']};' WHERE Nr={$_REQUEST['Nr']};"); <SCRIPT LANGUAGE="javascript"> <!-- window.open ('Examplepage.html') --> </SCRIPT> ........ ?> I have an age script running in the attachment below. It works fine for numbers such as 1 22 1980. Code: if ((input.search(/\b([1-9]|[12][0-9]|3[01])\b/)!= -1) && (input.search(/\b([1-9]|1[0-2])\b/)!=-1) && (input.search(/\b(19[0-9]{2}|200[0-9]|201[01])\b/)!= -1)) { function getBirth() { var now = new Date(); var myMatchy = input.match(/\b(19[0-9]{2}|200[0-9]|201[01])\b/); var myMatchm = input.match(/\b([1-9]|1[0-2])\b/) var myMatchd = input.match(/\b([1-9]|[12][0-9]|3[01])\b/); var year = myMatchy[0]; var month = myMatchm[0]; var day = myMatchd[0]; var today = { "year" : now.getFullYear(), "month": now.getMonth()+1, "day" : now.getDate() } var age = today["year"] - year; if (month > today["month"]) age--; else if (month == today["month"]) if (day > today["day"]) age-- return age; } document.result.result.value = "Your age is "+getBirth()+"."; return true;} However, if someone writes out the month it doesn't. Such as January 22 1980. I did a work-around by inserting the month value. Highlighted below. But that means I would have to duplicate this lengthy code 12 times for each month of the year. Anybody know a better way to handle this? You can test it in the small attachment below. Any help would be appreciated. Code: if ((input.search(/\b([1-9]|[12][0-9]|3[01])\b/)!= -1) && (input.search(/(january)/)!= -1) && (input.search(/\b(19[0-9]{2}|200[0-9]|201[01])\b/)!= -1)) { function getJan() { var now = new Date(); var myMatchy = input.match(/\b(19[0-9]{2}|200[0-9]|201[01])\b/); var myMatchd = input.match(/\b([1-9]|[12][0-9]|3[01])\b/); var month = 0; var year = myMatchy[0]; var day = myMatchd[0]; var today = { "year" : now.getFullYear(), "month": now.getMonth()+1, "day" : now.getDate() } var age = today["year"] - year; if (month > today["month"]) age--; else if (month == today["month"]) if (day > today["day"]) age-- return age; } document.result.result.value = "Your age is "+getJan()+"."; return true;} I have a Perl script that contains a variety of inputs including a HTML <SELECT> and RADIO buttons. I would like to alter the presentation of a RADIO button choice with a DISABLED, based upon the earlier selection of from a <SELECT> drop down menu. In Perl I attempted to capture the selection from the <SELECT> and use that value in a IF ELSE block, but this does not work. I have been told that this can be done with a Javascript. I did a little bit of coding with Javascript around five years ago, so I am a rusty newbie. Can anyone give me a hand on how this should be constructed? The more detailed your examples or suggestions can be the easier it will be for me to grasp the solution. Hey all I am not that much good in JS and J* kind of thigs .. help me out on this .. I am opening a Dhtmml poopup ,and it's having two buttons say YES and NO if user click on YES (mysql table) field say Yes should increse else if No (mysql table) field No should increse I hope understand the problem bascically on onclick I m using "window.open " a phpFile which is updating this all .. but I dont want to do this with window.open any help would be appreciated Thanks ayiamas Hi peeps I found this script on another forum, It is nearly perfect, I was wondering if you peeps could help me make a few changes... how do I change the cut off to 8pm I have tried var c_t = 8; but it does 8am I have also tried var c_t = 20; but it doesnt work... Any ideas? Also instead of just saying "your order will ship shifted to tommrow" would it be possible to insert tomorrows date, i.e Thursday 13th and then for "and your order will ship to Monday" could it say Monday 15th etc Here is the script, Code: <html> <head> <script type="text/javascript"> function ord() { var c_t = 4; var dd = new Date(); var ti_h = dd.getHours(); var ti_m = dd.getMinutes(); if(ti_h > c_t) { var di_t_h = ti_h - c_t; var di_t_mi = 60 - ti_m; var h = 24 - di_t_h; var mi = di_t_mi; var mess = h+"hours"+mi+"minutes"; } var da = dd.getDay(); //var da = document.getElementById("da").value; switch(da) { case 2: case 3: case 4: case 5: document.write("Place your order within the next 1 day"+mess+"and your order will ship shifted to tommrow"); break; case 6: case 7: case 1: document.write("and your order will ship to Monday"); break; } } ord(); </script> </head> <body> </body> </html> Hi, I am trying to add one image in footer of my application. Code: <div class="rightLinks"> <a href="#"><script src=https://seal.somesign.com/getseal?host_name=www.validsite.com&size=S&use_flash=NO&use_transparent=NO&lang=en></script></a> </div> But this is not working. Please let me know, what is wrong in it. And how can we correct it. Thanks!! Regards, Neha |