JavaScript - Javscript Not Aworking?!
I don't think it's calling teh function: setzoomimage when i click on Magnify
Code: <html> <head> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" src="flash/swfobject.js"></script> <script> // store the contents of the main image when zoomified used var mainimagesafe = ""; //swaps the main product images //on __incMain.asp function removezoom() { if(mainimagesafe != "") { var d = document.getElementById('mainimagecontainer'); var olddiv = document.getElementById('flashZoomer'); d.removeChild(olddiv); document.getElementById('mainimagecontainer').innerHTML = mainimagesafe; mainimagesafe = ""; } } function setzoomimage(){ if( mainimagesafe != "") { removezoom(); } else { swapcolour("altview5"); mainimagesafe = document.getElementById("mainimagecontainer").innerHTML; var so = new SWFObject("flash/flashZoomer_blackDiamond310_500.swf", "flashZoomer", 310, 500, "8", "#EFEBE2"); so.addParam("quality", "high"); so.addParam("scale", "noscale"); so.addParam("salign", "tl"); so.addVariable("imgSrc", "images/BigFlower03_002Main.png"); so.addVariable("zoomSteps", "5"); so.addVariable("startState", "select"); so.write("mainimagecontainer"); } } </script> </head> <body> <table> <tr> <td style="width:310px; vertical-align:top;"> <div id="mainviewimage"> <div id="mainimagecontainer"><img id="mainimage" src="images/BigFlower03_003Zoom.png" height="520" width="310" alt="" /></div> <span id="altview5" style="cursor:pointer;display:inline;float:right;" onclick="setzoomimage();">CLICK TO MAGNIFY <img style="vertical-align:bottom;" src="images/magnify.png" alt="" /></span> <span id="altview" style="cursor:pointer;" onclick="javascript:swapcolour('altview');swapMainImage('images/BigFlower03_003Zoom.png');"> 1</span> </div> </td> </tr> </table> </body> </html> Similar TutorialsHey, I need help big time as my site has just completly buggered up lol! I just made a JS script which laoads data into a div (ajax style) which means page refreshes are not required... but currently it loads a $pagename.php "contents" in to the div - but i cannot have this method. What i need it to do - is generate a string with the $pagename.php and inject that to a variable into the div... heres what i got: This works as its meant to - but needs to be changed to suit my new method: Code: var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no) var loadedobjects="" var rootdomain="http://"+window.location.hostname var bustcacheparameter="" function ajaxpage(url, containerid){ var page_request = false if (window.XMLHttpRequest) // if Mozilla, Safari etc page_request = new XMLHttpRequest() else if (window.ActiveXObject){ // if IE try { page_request = new ActiveXObject("Msxml2.XMLHTTP") } catch (e){ try{ page_request = new ActiveXObject("Microsoft.XMLHTTP") } catch (e){} } } else return false page_request.onreadystatechange=function(){ loadpage(page_request, containerid) } if (bustcachevar) //if bust caching of external page bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime() page_request.open('GET', url+bustcacheparameter, true) page_request.send(null) } function loadpage(page_request, containerid){ if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)) document.getElementById(containerid).innerHTML=page_request.responseText } function loadobjs(){ if (!document.getElementById) return for (i=0; i<arguments.length; i++){ var file=arguments[i] var fileref="" if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding if (file.indexOf(".js")!=-1){ //If object is a js file fileref=document.createElement('script') fileref.setAttribute("type","text/javascript"); fileref.setAttribute("src", file); } else if (file.indexOf(".css")!=-1){ //If object is a css file fileref=document.createElement("link") fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css"); fileref.setAttribute("href", file); } } if (fileref!=""){ document.getElementsByTagName("head").item(0).appendChild(fileref) loadedobjects+=file+" " //Remember this object as being already added to page } } } With that and this below is how it all works on the site so far: Code: <a href="javascript:ajaxpage(login.php','contentarea');">Link to login</a> <div id="contentarea"></div> How ever i need to change this so instead of it just "loading the page contents" into the div i want the JS to do similiar idea of loading into the div but merely pass php into it so i can do this: Code: <a href="javascript:ajaxpage(login.php','contentarea');">Link to login</a> <div id="contentarea"> <?php include($name); //$name being "login.php" due to above href //$name value needs to be made from the JS from getting the //url in the HREF whilst not refreshing the page to do so. ?> </div> Can some one help me edit my JS to do what im trying to do ? I'm stuck at this point at trying to get it to do this final part. I have this php validation string
Code: $urlregex = "^(https?|ftp)\:\/\/([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*(\:[0-9]{2,5})?(\/([a-z0-9+\$_-]\.?)+)*\/?(\?[a-z+&\$_.-][a-z0-9;:@/&%=+\$_.-]*)?(#[a-z_.-][a-z0-9+\$_.-]*)?\$"; and i want it to convert into javascript. please help The onChange is not calling my subroutine. I haven't played with JS in a few years, I'm sure this is stupidly simple. Any help is appreciated (or simpler way to do it!) Page is http://tinyurl.com/23l4k6w Here's the relevant code: Code: <form name="jump2"> <select name="comps"> <option value="0" selected># of Computers</option> <option value="1">1 Computer</option> <option value="2">2 Computers</option> <option value="3">3 Computers</option> <option value="5">5 Computers</option> <option value="10">10 Computers</option> </select> <select name="years" onchange="jump();"> <option value="0" selected>Years of Protection</option> <option value="1">1 Year</option> <option value="2">2 Years</option> </select> </form> <iframe name="buy_frame" src="" width="992" height="500" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe> <script language="javascript"> <!-- function jump() { if (jump2.comps.options[selectedIndex].value == 1) { if (jump2.years.options[selectedIndex].value == 1) { window.open('https://secure.element5.com/esales/checkout.html?PRODUCT[300318987]=1&languageid=1&backlink=http%3A%2F%2Fwww.smartboxllc.com&cookies=1&nolselection=1&noquickbuy=1&showcart=1&affiliateid=200079763','buy_frame'); } if (jump2.years.options[selectedIndex].value == 2) { window.open('https://secure.element5.com/esales/checkout.html?PRODUCT[300199167]=1&languageid=1&backlink=http%3A%2F%2Fwww.smartboxllc.com&cookies=1&nolselection=1&noquickbuy=1&showcart=1&affiliateid=200079763','buy_frame'); } } if (jump2.comps.options[selectedIndex].value == 2) { if (jump2.years.options[selectedIndex].value == 1) { window.open('https://secure.element5.com/esales/checkout.html?PRODUCT[300199158]=1&languageid=1&backlink=http%3A%2F%2Fwww.smartboxllc.com&cookies=1&nolselection=1&noquickbuy=1&showcart=1&affiliateid=200079763','buy_frame'); } if (jump2.years.options[selectedIndex].value == 2) { window.open('https://secure.element5.com/esales/checkout.html?PRODUCT[300199168]=1&languageid=1&backlink=http%3A%2F%2Fwww.smartboxllc.com&cookies=1&nolselection=1&noquickbuy=1&showcart=1&affiliateid=200079763','buy_frame'); } } if (jump2.comps.options[selectedIndex].value == 3) { if (jump2.years.options[selectedIndex].value == 1) { window.open('https://secure.element5.com/esales/checkout.html?PRODUCT[300199159]=1&languageid=1&backlink=http%3A%2F%2Fwww.smartboxllc.com&cookies=1&nolselection=1&noquickbuy=1&showcart=1&affiliateid=200079763','buy_frame'); } if (jump2.years.options[selectedIndex].value == 2) { window.open('https://secure.element5.com/esales/checkout.html?PRODUCT[300199169]=1&languageid=1&backlink=http%3A%2F%2Fwww.smartboxllc.com&cookies=1&nolselection=1&noquickbuy=1&showcart=1&affiliateid=200079763','buy_frame'); } } if (jump2.comps.options[selectedIndex].value == 5) { if (jump2.years.options[selectedIndex].value == 1) { window.open('https://secure.element5.com/esales/checkout.html?PRODUCT[300199160]=1&languageid=1&backlink=http%3A%2F%2Fwww.smartboxllc.com&cookies=1&nolselection=1&noquickbuy=1&showcart=1&affiliateid=200079763','buy_frame'); } if (jump2.years.options[selectedIndex].value == 2) { window.open('https://secure.element5.com/esales/checkout.html?PRODUCT[300199170]=1&languageid=1&backlink=http%3A%2F%2Fwww.smartboxllc.com&cookies=1&nolselection=1&noquickbuy=1&showcart=1&affiliateid=200079763','buy_frame'); } } if (jump2.comps.options[selectedIndex].value == 10) { if (jump2.years.options[selectedIndex].value == 1) { window.open('https://secure.element5.com/esales/checkout.html?PRODUCT[300199161]=1&languageid=1&backlink=http%3A%2F%2Fwww.smartboxllc.com&cookies=1&nolselection=1&noquickbuy=1&showcart=1&affiliateid=200079763','buy_frame'); } if (jump2.years.options[selectedIndex].value == 2) { window.open('https://secure.element5.com/esales/checkout.html?PRODUCT[300199171]=1&languageid=1&backlink=http%3A%2F%2Fwww.smartboxllc.com&cookies=1&nolselection=1&noquickbuy=1&showcart=1&affiliateid=200079763','buy_frame'); } } if (jump2.comps.options[selectedIndex].value == 0) { alert("You must select # of computers."); } else { alert("else");} //--> </script> Greetings..... I am not quite sure where to place this question since it involves C#, javascript and even a call to SSRS. What I want to do is call a Sql Server Reporting Services Report, using javascript like so: Code: ClientScript.RegisterStartupScript(GetType(), "FrameUpdate", "<script language=\"JavaScript\">" + "\n" + "cursor_wait();" + "\n" + "window.location.href ='http://serverName/ReportServer?/myReport/my Information Report&rc:Parameters=false&ANumber=" + ViewState["ANumber"].ToString().Trim() + "&BNumber=" + ViewState["BNumber"].ToString() + "&Sort_Param=" + ViewState["sortField"].ToString() + "&Sort_Direction=" + ViewState["sortDirection"].ToString() +"&rc:Toolbar=false&rs:Command=render&rs:Format=PDF&rs:Zoom=Fit Page'; " + "\n" + "cursor_clear();" + "\n" + "<" + "/script>"); The code works and I can pull the correct report. The issue is I wanted some visual que for the user that the report was being gernerated. that is why i used the javascript functions : cursor_wait(), and cursor_clear(). The problem is I want to display a wait cursor untill the window with the report returns and displays the report then reset to the default cursor at that time. But the above code resets the cursor right away without waiting for the report to return. I tried adding attributes to the page form and other methods to access onBlur and such but haven't been able to get there yet. A very tricky problem. on http://d11882157.a148.awebforyou.com...14_1422_p.html I use a javascript zoom but it disables the users from clicking on the link above the zoom is there any solution for this? Hello all, essentially i am grabbing a variable from the query string and i need to pass that value into another script. allow me to explain; usually i use this code to display a persons email address from the query string onto the page using document.write <script> function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i<vars.length;i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } document.write(''); } </script> then i would display the var with this <script> document.write( getQueryVariable("Contact0Email") ); </script> ------------ ok so here is what i need to do. my client sent me the code below asking me to pass the email var into the javascript and image. my programmer friend said to use php and do smething like; <SCRIPT language="javascript" src="https://www.cpctrack.com/redirconsume.aspx?CID=25240&ORDERID=<? echo . $_GET['Contact0Email']; ?>"></SCRIPT> <NOSCRIPT><IMG src="https://www.cpctrack.com/redirconsume.aspx?CID=25240&p=img&ORDERID=<? echo . $_GET['Contact0Email']; ?>" width="1" height="1" border="0"></NOSCRIPT> this syntax does not work; <? echo . $_GET['Contact0Email']; ?> WHAT DO YOU GUYS THINK? Is the syntax wrong or are there better methods? Hi, I am working on a website now and I am experiencing problems with the gallery. It appears to work fine most of the time, however when you navigate between the galleries using the bottom left menu, occasionally either no large image will appear, and/or the thumbnails will highlight when rolled over, but nothing happens when clicked. I am using the Featured Content Slider from Dynamic Drive (Time was a concern getting this project done). The source code and pages can be viewed at http://www.metacomdesign.com/proofs/vfitz/current.html . Instead of posting snippets, I will just link to the whole thing, because I am not sure what parts to post. Thank you for your time Edit: Also, the pages that seem to be the culprits are Beauty and Covers/Advertising. Any help would be much appreciated Hi, I am using a multiple select with javascript to update the navigation bar <li> depending on which single option is selected and it's working well. The only problem however, is when multiple are selected, I want all a class to be added to all the <li> but it's not working. if (document.getElementById("status_advanced").value == "1"){ $('.moduleTitle').html("<h2>Enquiries</h2><span class='utils'> <a id='create_image' href='index.php?module=AOS_Invoices&action=EditView&return_module=AOS_Invoices&return_ac tion=DetailView' class='utilsLink'><img src='custom/themes/default/images/create-record.gif?v=9FuiS_EWfdVgVhHTU4vK3g' alt='Create'></a><a id='create_link' href='index.php?module=AOS_Invoices&action=EditView&return_module=AOS_Invoices&return_ac tion=DetailView' class='utilsLink'>Create</a></span>"); $("#enquiries-nav").addClass("currentTab"); $("#jobs-nav").removeClass("currentTab"); } else if (document.getElementById("status_advanced").value == "2"){ $('.moduleTitle').html("<h2>Jobs</h2>"); $("#jobs-nav").addClass("currentTab"); $("#enquiries-nav").removeClass("currentTab"); } else if (document.getElementById("status_advanced").value == "3"){ $('.moduleTitle').html("<h2>Clearance</h2>"); $("#clearance-nav").addClass("currentTab"); $("#jos-nav").removeClass("currentTab"); } else if ((document.getElementById("status_advanced").value == "1") && (document.getElementById("status_advanced").value == "2")){ $('.moduleTitle').html("<h2>All</h2>"); $("#enquiries-nav").addClass("currentTab"); $("#jos-nav").addClass("currentTab"); } Any suggestions? Reply With Quote 01-20-2015, 01:56 PM #2 Philip M View Profile View Forum Posts Supreme Master coder! Join Date Jun 2002 Location London, England Posts 18,371 Thanks 204 Thanked 2,573 Times in 2,551 Posts Suggest you have a select option "All". Use this example:- Code: <!DOCTYPE html> <html> <head> </head> <body> <form id="InventoryList" method="post" action=""> <select id="SelBranch" class="class1" size="5" multiple="multiple"> <option value="All Branches">All Branches</option> <option value="001 London">001 London</option> <option value="002 Birmingham">002 Birmingham</option> <option value="003 Manchester">003 Manchester</option> <option value="004 Nottingham">004 Nottingham</option> <option value="005 Bradford">005 Bradford</option> <option value="006 Newcastle">006 Newcastle</option> </select> <input type="button" id ="ViewReport" value="View" class="class1" onclick="GetInventory();"> </form> <script type = "text/javascript"> function GetInventory() { var sel = document.getElementById("SelBranch"); var count = 0; var SelBranchVal = []; for (x=0; x<sel.length; x++) { if (sel[x].selected) { SelBranchVal[count] = sel[x].value; count++; } } alert(SelBranchVal); } </script> </body> </html> Quizmaster: Which word for a spring or town with thermal or mineral waters used for drinking or bathing takes its name from a town in Belgium which is famed for its supposedly curative waters? Contestant: Volvic I had a thread on here earlier in which one of you helped me immensely. As I mentioned in that thread, I know very little about javascript. The code I was given basically handles one user, and does it very well. I have since attended a meeting in which I was asked to have multiple users on one page. For example: My current code handles the following: Name - Hours - series of radio button choices. My updated request is the following: Name - Hours - series of radio button choices Name - Hours - series of radio button choices Name - Hours - series of radio button choices Name - Hours - series of radio button choices etc. up to 15 total users. I have tried to adjust the javascript, but with my lack of knowledge in this area I keep breaking it. Any help would again be greatly appreciated, here is my code: Code: <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Jared Daily Sales Goal Calculation Worksheet</title> </head> <script type="text/javascript"> var IE = navigator.appName == "Microsoft Internet Explorer"; var nSets = ""; var answeredQ = []; function advanceTo(nextQ,nQ){ var currAns = answeredQ[nQ.name.replace(/q/,"")-1]; if (currAns != "-" && currAns != nQ.value) { var nFloor = nQ.parentNode.parentNode.id.replace(/f/,"")-1; for (i=0; i<nSets.length; i++) { if (i > nFloor) { nSets[i].style.display = "none"; } } } nSets[nextQ-1].style.display = ""; answeredQ[nQ.name.replace(/q/,"")-1] = nQ.value; } function init(){ nSets = document.forms[0].getElementsByTagName('fieldset'); for (i=1; i<nSets.length; i++) { nSets[i].style.display = "none"; answeredQ[answeredQ.length] = "-"; } } IE ? attachEvent('onload', init, false) : addEventListener('load', init, false); </script> <style type="text/css"> body {background-color: #ffffff; margin-top: 60px;} fieldset {border: 0px} td { font-family:Arial, Helvetica, sans-serif; font-size:12px;} h1 { font-family:Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold;} </style> <body> <cfform action="" method="post"> <!--- Header ---> <table border="1"> <tr> <td> <table align="left"> <tr bgcolor="#E5E5E5"> <td>Name</td> <td>Hours</td> <td colspan="4"></td> </tr> <!--- Emp 1 ---> <tr bgcolor="#ffffff"> <td valign="top"><input name="" size="10"></td> <td valign="top"><input name="" size="10"></td> <td valign="top"> <fieldset id="f1"> <!-- Question 1 --> <label><input type="radio" name="e1q1" value="Diamond1" onclick="advanceTo(2,this)">Diamond</label> <label><input type="radio" name="e1q1" value="Perimeter1" onclick="advanceTo(3,this)">Perimeter</label> </fieldset> </td> <td valign="top"> <fieldset id="f2"> <!-- Question 2 --> |<label><input type="radio" name="e1q2" value="GM1">GM</label> <label><input type="radio" name="e1q2" value="AGM1">AGM</label> <label><input type="radio" name="e1q2" value="DDM1">DDM</label> <label><input type="radio" name="e1q2" value="FT1" onclick="advanceTo(4,this)">Full Time</label> <label><input type="radio" name="e1q2" value="PT1" onclick="advanceTo(4,this)">Part Time</label> </fieldset> </td> <td valign="top"> <fieldset id="f3"> <!-- Question 3 --> <label><input type="radio" name="e1q3" value="PDM">PDM</label> <label><input type="radio" name="e1q3" value="RL">RL</label> <label><input type="radio" name="e1q3" value="FT1" onclick="advanceTo(4,this)">Full Time</label> <label><input type="radio" name="e1q3" value="PT1" onclick="advanceTo(4,this)">Part Time</label> </fieldset> </td> <td valign="top"> <fieldset id="f4"> <!-- Question 4 --> |<label><input type="radio" name="e1q4" value="Tenured1">Tenured</label> <label><input type="radio" name="e1q4" value="NonTenured1">Under 2 Years</label> </fieldset> </td> </tr> </table> </td></tr></table> </cfform> </body> </html> Hey there. I've recently written a small javascript library that creates a unified interface for localStorage and sessionStorage. The code is here http://github.com/AndrewLowther/StorageItem I'm looking for people to give me feedback and to help me work on it should you so wish. Feedback is most welcome! |