JavaScript - Need Help With Showdiv Function
Similar TutorialsCan anyone look at some code to tell me what I am doing wrong. The hide and show feature work if the item is on the same page. If I want to have a link drop to another page, this code does not work. 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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Peake Healthcare Innovations-Company</title> <script type="text/javascript"> <!-- function MM_swapImgRestore() { //v3.0 var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc; } function MM_preloadImages() { //v3.0 var d = document; if (d.images) { if (!d.MM_p) d.MM_p = new Array(); var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++) if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } } } function MM_findObj(n, d) { //v4.01 var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) { d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p); } if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n]; for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document); if (!x && d.getElementById) x = d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3) if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; } } function goto(pID) { document.getElementById(pID).scrollIntoView(); } function showDiv(pdiv) { switch (pdiv.toLowerCase()) { case "company": document.getElementById(pdiv).style.display = 'inline'; document.getElementById("companysplash").style.display = 'inline'; document.getElementById("codiv").style.display = 'none'; document.getElementById("performance").style.display = 'none'; document.getElementById("differentiates").style.display = 'none'; document.getElementById("multiuse").style.display = 'none'; break; case "codiv": document.getElementById(pdiv).style.display = 'inline'; document.getElementById("company").style.display = 'none'; document.getElementById("performance").style.display = 'none'; document.getElementById("differentiates").style.display = 'none'; document.getElementById("companysplash").style.display = 'none'; document.getElementById("multiuse").style.display = 'inline'; break; case "performance": document.getElementById(pdiv).style.display = 'inline'; document.getElementById("company").style.display = 'none'; document.getElementById("codiv").style.display = 'none'; document.getElementById("differentiates").style.display = 'none'; document.getElementById("companysplash").style.display = 'none'; document.getElementById("multiuse").style.display = 'inline'; break; case "differentiates": document.getElementById(pdiv).style.display = 'inline'; document.getElementById("company").style.display = 'none'; document.getElementById("codiv").style.display = 'none'; document.getElementById("performance").style.display = 'none'; document.getElementById("multiuse").style.display = 'inline'; document.getElementById("companysplash").style.display = 'none'; break; } } //--> </script> <script type="text/javascript" src="../dropdowntabs/dropdowntabfiles/dropdowntabs.js"></script> <link href="styles/main.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" type="text/css" href="script/new_droptabs.css"> </head> <body bgcolor="#999999" onload="MM_preloadImages('images/rt_bar_glow_repeater.gif')"> <table width="967" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF"> <tr> <td> <script type="text/javascript"> //SYNTAX: tabdropdown.init("menu_id", [integer OR "auto"]) tabdropdown.init("colortab", 3) </script> <div id="dropmenu" class="top-menu"> <ul> <li><a href="index.html"><span class="whitelink">Home</span></a></li> <li><a href="company.html" rel="dropmenu1_b"><span class="whitelink">Company</span></a></li> <li><a href="community.html" rel="dropmenu2_b"><span class="whitelink">Community</span></a></li> <li><a href="services.html" rel="dropmenu3_b"><span class="whitelink">Services</span></a></li> <li><a href="solutions.html" id="last-link" tile="Solutions" rel="dropmenu4_b"><span class="whitelink">Solutions</span></a></li> </ul> </div> <!--1st drop down menu/Company --> <div id="dropmenu1_b" class="dropmenudiv_b"> <a href="javascript:%20showDiv('performance');">Peake Performance</a> <a href="javascript:%20showDiv('differentiates');">What Differentiates Us</a> </div> <!--2nd drop down menu/Community --> <div id="dropmenu2_b" class="dropmenudiv_b" style="width: 150px;"> <a href="../dropdowntabs/Community.html" id="collaboration">Collaboration</a> </div> <!--3rd drop down menu/Services --> <div id="dropmenu3_b" class="dropmenudiv_b" style="width: 150px;"> <a href="javascript:%20showDiv('singleplace');">Acessability</a> <a href="javascript:%20showDiv('portfolio');">Peake Portfolio</a> </div> <!--4th drop down menu/Solutions --> <div id="dropmenu4_b" class="dropmenudiv_b" style="width: 150px;"> <a href="javascript:%20showDiv('strategy');">Imaging Strategy</a> <a href="javascript:%20showDiv('imagesharing');">Image Sharing</a> </div> </td> </tr> <tr> <td> <!--PBanners to go here--> <table width="967" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <div id="affiliate">An affiliate of Harris Corporation and Johns Hopkins Medicine</div></td> </tr> <tr> <td> <div style="display: inline;" id="companysplash"> <img src="images/focal_layered.jpg" alt="Peake Healthcare Innovations" width="967" height="195" border="0" usemap="#Map" /> </div> <div style="display: none;" id="multiuse"> <img src="images/Peake_Multiuse_Banner.jpg" width="967" height="140" alt="Peake Healthcare Innovations" /> </div> </td> </tr> </table> <!--End Banners here--> </td> </tr> <tr> <td height="29"> <table width="967" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="728" valign="top"> <!--Start Main Content Company --> <div style="display: inline;" id="company"> <div class="title"> Headline Goes Here</div> <fieldset style="float:right; width:200px; height:400px; border:0;"> <img src="images/Service_Assets_Placeholder.jpg" width="160" height="111" alt="Service Assets Placeholder" /><br/> <div class="callout_title">THE PEAKE TEAM</div> <div class="callout_text">Read more about the <br/>Peake Team<i></i></div> <div class="callout_link"><a href="http://www.harris.com">MORE</a> ></div> <br/> <img src="images/Harris_Corporate_Building.jpg" width="160" height="111" alt="Service Assets Placeholder" /><br/> <div class="callout_title">PEAKE PARTNERS</div> <div class="callout_text">Delivering a way to better healthcare by working together<i></i></div> <div class="callout_link"><a href="http://www.harris.com">MORE</a> ></div> <p> </p> </fieldset> <div class="subhead">Subhead to go here</div> <div class="bodylg">Founded in March 2011, Baltimore-based Peak Healthcare Innovations (Peake) offers the first complete, cloud-based medical image management solution for global markets. </div> <br/> <div class="content">Peake was formed as a joint venture between two widely recognized market leaders: Johns Hopkins Medicine and Harris Healthcare Solutions. Peake blends the prowers of Hopkins' clinical and research expertise with Harris Corporation's proven track record in the application of Interoperability best practices, secure communications and managed services for national IT infrastructures. <a href="javascript:%20showDiv('codiv');">LEARN MORE</a> ></div></div> <br/> </div> <!--End Main Content Company --> <br/> <!--Start Secondary Content Company --> <div style="display: none;" id="codiv"> <table width="291px" border="0" cellpadding="0" cellspacing="0" class="callout_table" style="float:left"> <tr> <td height="44" colspan="3"><img src="images/left_placeholder.gif" width="291" height="325" /></td> </tr> <tr> <td height="35" colspan="3" class="callout_header">Related Items</td> </tr> <tr> <td width="49%" height="88"> <fieldset style="padding:5px; height:115px;"> <div class="callout_title">PEAKE PERFORMANCE</div> <div class="callout_text">Peake gets it–<br/><i>Physicians never wait</i></div> <div class="callout_link"><a href="javascript:%20showDiv('performance');">MORE</a> ></div> </fieldset> </td> <td width="2%" height="88"> </td> <td width="49%"> <fieldset style="padding:5px; height:115px;"> <div class="callout_title">PEAKE DIFFERENCES</div> <div class="callout_text">An uncommon solution provider in a rapidly evolving marketplace</div> <div class="callout_link"> <a href="javascript:%20showDiv('differentiates');">MORE</a> ></div> </fieldset> </td> </tr> </table> <img src="images/The_Peake_Company_Title.jpg" width="350" height="22" alt="The Peake Company" /> <div class="subhead">Unprecedented Performance at the point of care.</div> <div class="content">Peake's mission is to improve the quality of patient care and the efficiency of the patient care delivery process through transformatice innovation in health information management. By building on the strength of open-source software, Peak will could-enable the medical imaging practices of hospitals, integrated delivery networks, and health information exchanges with unprecedented performance at the point of care. Our secure, redundant, reliable cloud-based solutions facilitate colllaboration within and accross enterprise boundaries connecting care providers and patients like never before.<br/></div> <div class="content"> <fieldset style=" padding-left:7px; padding-right:7px; padding-top:3px;"> <div class="callout_titleb">PEAKE GENERATES VALUE FOR THE HEALTHCARE ENTERPRISE IN TWO WAYS:</div> <ul> <li>The significant decuction in cost of imaging operations </li> <li>An improvement of access to mission critical information</li> </ul> </fieldset> <br/> This is achieved through our partnership-oriented business model that places emphasis on performance and services. With no up front capital expense and scaled on the performance of your imaging businemass, our world class services are provided as an essentail utility in a pure, operational expense model. We combine our extensive development efforts with the industry's best applications to empower healthcare providers with choice. The choice of clinical, diagnostic and advanced 3D solutions as well as other workflow optimizing services that speed the adoption of technology and the care delivery process. Our customers now have technology packaged as a flexible service eliminating the burden associated with "vendor lock" to best meet the needs of clinicians, patients and communities today, tomorrow, and in the future. </div> </div> <!--End Secondary Content Company --> <!--Start Secondary Performance Content Company --> <div style="display: none;" id="performance"> <table width="291px" border="0" cellpadding="0" cellspacing="0" class="callout_table" style="float:left"> <tr> <td height="44" colspan="3"><img src="images/left_placeholder.gif" width="291" height="325" /></td> </tr> <tr> <td height="35" colspan="3" class="callout_header">Related Items</td> </tr> <tr> <td width="49%" height="88"> <fieldset style="padding:5px; height:115px;"> <div class="callout_title">PEAKE PERFORMANCE</div> <div class="callout_text">Peake gets it–<br/><i>Physicians never wait</i></div> <div class="callout_link"><a href="javascript:%20showDiv('performance');">MORE</a> ></div> </fieldset> </td> <td width="2%" height="88"> </td> <td width="49%"> <fieldset style="padding:5px; height:115px;"> <div class="callout_title">PEAKE DIFFERENCES</div> <div class="callout_text">An uncommon solution provider in a rapidly evolving marketplace</div> <div class="callout_link"><a href="javascript:%20showDiv('differentiates');">MORE</a> ></div> </fieldset> </td> </tr> </table> <div class="title"> Headline Goes Here</div> <div class="subhead">Achieve Peake Performance in Your Imaging Practice</div> <div class="content">Peake Healthcare Innovations believes that enterprise imaging solutions should be based on strong financial value, effective clinical utility and uncompromising reliability. While most vendors charge millions of dollars for software applications that place a significant burden on IT staff and disrupt clinical practice, Peake provides the world's most scalable, powerful and versatile Vendor Neutral Archive (VNA) at NO COST of software. Peake builds on the strength and popularity of DCM4CHEE, an open source software project established in 2000, as the basis for a commercial, cloud-based archiving solution. By returning Peake's substantive improvements to this proven application back to the healthcare community, our solutions uniquely offer what healthcare providers have been seeking from their vendor partnerships all along: <strong>choice</strong>. </div> <div class="content"> While healthcare providers, health information exchanges and accountable care organizations are unique in their size, scope and operations, most face the same challenges–increasing costs, decreasing reimbursement and changing regulation. Peake is dedicated to providing a complete image management solution offering to meet your needs. From cross-enterprise image exchange to clinical, diagnostic, and advanced 3D visualization, to a unified clinical image archive solution, disaster recovery and business continuity, Peake has what you need with the performance, security and reliability you would expect from an on-premise solution–at a fraction of the cost.</div> <div class="content"><strong>Connect, communicate, and collaborate within the enterprise and across the continuum of care.<br/> eake gets it—<i>Physicians never wait</i>.</strong> </div> </div> <!--End Secondary Performance Content Company --> <!--Start Secondary Differences Content Company --> <div style="display: none;" id="differentiates"> <table width="291px" border="0" cellpadding="0" cellspacing="0" class="callout_table" style="float:left"> <tr> <td height="44" colspan="3"><img src="images/left_placeholder.gif" width="291" height="325" /></td> </tr> <tr> <td height="35" colspan="3" class="callout_header">Related Items</td> </tr> <tr> <td width="49%" height="88"> <fieldset style="padding:5px; height:130px;"> <div class="callout_title">PEAKE PERFORMANCE</div> <div class="callout_text">Peake gets it–<br/><i>Physicians never wait</i></div> <div class="callout_link"><a href="javascript:%20showDiv('performance');">MORE</a> ></div> </fieldset> </td> <td width="2%" height="88"> </td> <td width="49%"> <fieldset style="padding:5px; height:130px;"> <div class="callout_title">ABOUT PEAKE </div> <div class="callout_text">The first complete cloud-based medical image management solutions for global markets</div> <div class="callout_link"><a href="javascript:%20showDiv('company');">MORE</a> ></div> </fieldset> </td> </tr> </table> <div class="title"> Headline Goes Here</div> <div class="subhead">What differentiates us?</div> <div class="content">Have no doubt, Peake is an uncommon solution provider in a rapidly evolving commercial marketplace. Unlike vendors that offer costly, siloed, often proprietary, software applications, Peake partners with our customers to create a unique solution that delivers the clinical applications and workflow your medical staff require as a service–improving the cost and effectiveness of care delivery. This innovative approach provides the flexibility and choice needed to continually improve your competitiveness in an otherwise uncertain reimbursement environment.<br/><br/> <fieldset style="padding:8px;"> <div class="callout_title">ALL OF OUR SERVICE OFFERINGS:</div> <ul> <li>Operate on a standards-based, highly secured, 3x redundant cloud platform</li> <li>Enhance and augment standards related to DICOM, IHE, and HL7 </li> <li>Were developed with unique technologies to accelerate and improve the performance and reliability of conventional image management solutions</li> <li>Provide a simple, flexible operational cost basis for delivery–no upfront capital is required</li> <li>Reduce the cost associated with medical imaging information technology by 15-30% annually</li> <li>Combine the experience and knowledge of Harris Corporation and Johns Hopkins Medicine to provide you a trusted, technology services partner </li> </ul> </fieldset> </div> </div> <!--End Secondary Differences Content Company --> </td> <!--End Main Content--> <!--Start What's New Column--> <td width="239" rowspan="2" valign="top"> <table width="239" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="whatsnew"> </td> </tr> <tr> <td> <img src="images/wedge.gif" width="238" height="13" /></td> </tr> <tr> <td colspan="3" height="45px" class="frame"> <div class="rtbarheader">LATEST NEWS</div> <p class="rtbar">Check back soon for the latest news.</p> </td> </tr> <tr> <td colspan="3" height="45px" class="frame"> <div class="rtbarheader">CURRENT DOWNLOADS</div> <p class="rtbar">Check back soon for downloads.</p> </td> </tr> <tr> <td colspan="3" height="158px" class="frame" > <div class="rtbarheader">UPCOMING EVENTS</div> <p class="rtbar">Peake will be at RSNA 2011 on Nov. 27–Dec. 2, 2011 for the 97th Scientific Assembly and Annual Meeting.</p> <p class="rtbar">Meet Peake at the HIMSS12 Annual Conference and Exhibition on Feb. 20–24, 2012 at the Venetian Sands Expo Center in Las Vegas, NV.</p> </td> </tr> <tr> <td colspan="3" height="7"><img src="images/whats_new_hairline_bottom.gif" width="238" height="7" /></td> </tr> </table> </td> <!--End What's New Column--> </tr> </table> </td> </tr> <tr> <td height="214"> <!--Footer input to go here --> </td> </tr> </table> <map name="Map" id="Map"> <area shape="rect" coords="11,43,239,155" href="index.html" target="_self" alt="Peake Healthcare Innovations" /> </map> </body> </html> <!--This script here will tell the code which instance to show first--> <script> showDiv('company'); </script> <script type="text/javascript"> //SYNTAX: tabdropdown.init("menu_id", [integer OR "auto"]) tabdropdown.init("dropmenu") </script> <!--End Section--> Hi, I am facing a problem in passing replace() function as an argument in user defined java function, can any one help me how to resolve it? intention is to pass a file path to my user defined function, but before passing the path i want to replace the character '\' to '\\' I am posting my javascript function he <a href="#" onclick="OpenDocPreview('<%# Eval("PATH")%>'.replace(/\\/g,"\\\\"), '<%# Eval("Filename")%>')"><%# Eval("DocTitle") %></a> function OpenDocPreview(url, docname) { alert('message from search base : ' + url + ' ' + docname); } thank you, I was working on a tutorial for some ajax uploading stuff and I ran across a new function syntax I don't recognize. I am not a Javascript pro, but I am not a newbie either. here is the code I am working on: Code: function handleFileSelect(e){ var files = e.target.files; var output = []; for(var i=0,f;f=files[i];i++){ if(f.type.match('image.*')){ var reader = new FileReader(); reader.onload = (function(theFile){ return function(e){ var span = document.createElement('span'); span.innerHTML = ['<img class="thumb" src="',e.target.result,'" title="',theFile.nbame,'" />'].join(''); document.getElementById('list').insertBefore(span,null); }; })(f); reader.readAsDataURL(f); } } document.getElementById('list').innerHTML = '<ul>'+output.join('')+'</ul>'; } document.getElementById('files').addEventListener('change',handleFileSelect,false); To be a little more clear, the code in question is that is the very middle. The syntax I don't understand is: Code: class.event = (function(arguments){ //stuff you put in a function... })(more Arguments?); I tried to customize a simple one to learn for myself and I wrote this: Code: var a = 'A'; var b = 'B'; test = (function(t){ alert(t); alert(b); })(b); test(a); The browser would alert 'B' and that's it. The console would tell me that 'test is not a function.' OK, so I am confused. The topmost code works. What I am wondering is what the syntax is called for creating a function (or event listener?) that way, and how it works. Although if I new what it was called I could just google how it works. i keep getting error Call to undefined function codeandurl() below is my code PHP Code: <?php $value= strip_tags(get_field('link',$post)); $resultid=get_field('resultid',$post); codeandurl($resultid,$value); ?> <div id="result"></div> <script type="text/javascript"> function codeandurl(resultid,url){ $( "#result" ).text(resultid); $( "#result" ).dialog({ modal: true, buttons: { Ok: function() { $( this ).dialog( "close" ); } } }); window.open(url); return false; } </script> Hi! I'm trying to toggle a class and one works and the other does not and I don't know why. I'm just getting my feet wet with jquery and javascript and I figured this was a pretty easy task to take on! Maybe. Link to the page: Franklin Township Soccer Club - Change Field Status My sad, sorry attempt =| Code: $( "li.open" ).click(function() { $( this ).toggleClass( "closed" ); }); $( "li.closed" ).click(function() { $( this ).toggleClass( "open" ); }); The first function works with open, so I figured I'd just use opposite on closed! Ha! I don't think so! In the end within those function there is an element in a form on that page it's hidden. I'd like to change the value from a 0 to 1 for vice versa. That' will be my next step. If you could give me a little nudge in the right direction I'd appreciate it! But first understanding why one works and the other does not, that is the primary mission! I do appreciate any help given! Dave Hi All, I'm trying to convert an anonymous function to a real function (nesting is getting out of hand), however the msg object becomes undefined after conversion. Here is the converted anonymous function which fails: https://gist.github.com/2587613 and here is the original anonymous function which works: https://gist.github.com/2587667 Any help would be greatly appriciated I found this script, and it works great: Code: <script type="text/javascript"> function disable(element) { var input = document.getElementById(element).getElementsByTagName("input"); for(var i = 0; i < input.length; i++) { input[i].setAttribute("disabled","true"); } } </script> I tried to make the inverse by simply reversing the setAttribute() like so: Code: <script type="text/javascript"> function enable(element) { var input = document.getElementById(element).getElementsByTagName("input"); for(var i = 0; i < input.length; i++) { input[i].setAttribute("disabled","false"); } } </script> But that didn't do it. Can someone show me why, and how to fix it? Here's the sample form which I'm trying to test it on: Code: <form> <input type="radio" name="test" onclick="disable('D1')" /> disable<br/> <input type="radio" name="test" onclick="enable('D1')" /> enable<br/> <fieldset id="D1"> <input class="" type="text" value="test value1" /><input class="" type="text" value="test value2" /><br/> <input class="" type="text" value="test value3" /><input class="" type="text" value="test value4" /><br/> <input class="" type="text" value="test value5" /><input class="" type="text" value="test value6" /><br/> </fieldset> </form> Edit: The ultimate goal which I'm working toward now (step by step =) is to have a form more like: Code: <form> <input type="radio" name="test" onclick="disable('D1')" /> <fieldset id="D1"> <input class="" type="text" value="test value1" /><input class="" type="text" value="test value2" /> </fieldset> <input type="radio" name="test" onclick="disable('D2')" /> <fieldset id="D2"> <input class="" type="text" value="test value3" /><input class="" type="text" value="test value4" /> </fieldset> <input type="radio" name="test" onclick="disable('D3')" /> <fieldset id="D3"> <input class="" type="text" value="test value5" /><input class="" type="text" value="test value6" /> </fieldset> </form> And have the fieldsets enable and disable according the selection of the radio buttons. Also, the fieldsets (and their ID's) will be dynamically generated via PHP Thanks-a-bunch, ~ Mo <p> <script type="text/javascript">// <![CDATA[ var metrics = { "mm" : 1, "cm" : 10, "m" : 1000, "inch" : 25.4, "foot" : 304.8 }; function convert(num, dec){ var val = document.getElementById("fromVal").value; if(isNaN(val)){ return } function roundNumber(num, dec) { var result = Math.round( Math.round( num * Math.pow( 10, dec + 1 ) ) / Math.pow( 10, 1 ) ) / Math.pow(10,dec); return result; } document.getElementById("toVal").value = val * metrics[document.getElementById("fromSystem").value]/ metrics[document.getElementById("toSystem").value]; } var interval = null; function watchChanges(){ interval == null ? setInterval("convert()", 500) : clearInterval(interval); } // ]]></script> </p> <table> <tbody> <tr> <td><input id="fromVal" style="width: 100px;" onfocus="watchChanges()" onblur="watchChanges()" type="text" /><select id="fromSystem" onchange="convert()"> <option value="mm">millimeters</option> <option selected="selected" value="cm">centimeters</option> <option value="m">meters</option> <option value="foot">feet</option> <option value="inch">inches</option> </select></td> </tr> <tr> <td colspan="1" align="center">=</td> </tr> <tr> <td><input id="toVal" style="width: 100px;" type="text" disabled="disabled" /><select id="toSystem" onchange="convert()"> <option value="mm">millimeters</option> <option value="cm">centimeters</option> <option value="m">meters</option> <option selected="selected" value="foot">feet</option> <option value="inch">inches</option> </select></td> Hi, Any one help me In one variable i have some data ex: var data = document.getElementById("imageId").value; I want to pass this data to another function inside another function ex: var button1 = '<img src="images/Remove-button.gif" width="70" height="15" onclick="removeVerifyImageRow(this),saveLibData('+data+')"/>'; while running the application i am getting an error incase if the data is string ex:if data is 'image1' i am getting an error, but with number there is no problem ex: if data is '1122'. this is very urgent to solve this problem plz any one help me Thank you in advance if someone can help. I have been banging my head against the wall for hours now. Here is the code: Code: for (var i = 0; i < BS_crm['activityTypes'].length; i++) { var clickFunc = function(){ activityList.showForm( -1, {blockType:[""+BS_crm['activityTypes'][i]['id'], "0"]} ); }; var type = { value: BS_crm['activityTypes'][i]['id'], label: "Add New "+BS_crm['activityTypes'][i]['label'], css: BS_crm['activityTypes'][i]['css']+"_16", onClick: clickFunc }; previewLinks.items.push( type ); } Now, basically what I am doing here is running through one array to create an array of objects, that will be used to create links that will use whatever onClick function I pass it. The problem is that on the second line I need the BS_crm['activityTypes'][i]['id'] to be a value, not a reference. If that line was simply changed to: Code: var clickFunc = function(){ activityList.showForm( -1, {blockType:["3", "0"]} ); }; then everything would work as I need. How can I make this happen? I would really appreciate any help. Thank you again in advance. I made a mouseover event of a caption on a picture, when I hover the opacity of the background color of the hover and the text goes down. What I want is that when I hover over the image which the caption is floating on, the onmouseover event gets activite. For an imaginary example: Code: function unhighlight(x) { x.style.backgroundColor="transparent" } Function ActivationFuction() { activate.function="unhighlight" } thanks How can I call a PHP Function inside a Javascript Function? This is what I have so far, but I don't think I'm doing it the right way. Any suggestions? PHP Code: <?php function phpQuery(){ $query = mysql_query("INSERT INTO mytable VALUES('','name','email')"); } ?> <script type="text/javascript"> function delayQueries() { timeoutID = window.setTimeout(doQueries, 2000); } function doQueries() { var runQuery = "<?php phpQuery(); ?>"; } </script> I'm trying to "progressively enhance" one of my surveys using javascript. Basically, I have rating scales that make use of radio buttons as each point on the scale. Each radio button occupies its own cell in a table. I wrote some functions that will highlight cells on mouseover in a color corresponding to its position on the scale (e.g. the lowest point is red, the midpoint is yellow, the highest point is green). When a radio button is clicked, the background of the button's cell and preceding cells in the same row will be colored accordingly. The functions are working well in FireFox and Chrome (I just have to add a few lines using the addEvent function to make it compatible with IE). The effect looks a lot nicer when I add a function that makes the visibility of the radio buttons hidden. However, I want to make sure that there is a fallback option in case the functions that color the cells don't work for whatever reason. I would not want the radio buttons hidden in this case. Is there a method whereby I can call the "hideRadiobuttons" function only if the other functions are successfully executed? Code: <html> <head> <title>TESTING</title> <script type="text/javascript"> <!-- document.write("<input type='submit' value='submit' onclick='func()'>"); function func() { document.write("<input type='submit' value='New Button' onclick='func()'>"); window.alert("THIS"); } --> </script> </head> <body> <!--input type="button" value="Read" onclick="ReadFiles()"--> </body> </html> This is a very basic version of what I am trying to do. I have a dynamic list which is set in a table. When clicked, a function is run to set up a new list.. The reason I explain that, is that I need to keep it dynamic. Now for the problem: When I run this page, I have the button made right away, then when clicked it creates the new button. The new button should also run the function to create the new button again, but when I click it, I only receive "error on page". I don't know if there is a better way to go about this, but as for this route, I am stuck. Any help is greatly appreciated! -Shane Hello all. I have fairly simple questions regarding modifying this script: http://papermashup.com/create-a-dynamic-form-preview/ to dynamically show different parts of a form on another part of the page. I am looking to use it on most parts of my form and would like a little clarification. First is the use of $(document).ready(function() or $(function(). It works using either, my question is which is preferred? As I understand it using $(document).ready(function() starts the DOM immediately on page load and is useful if you need something right away. I am also using this script: http://www.dynamicdrive.com/dynamici...formwizard.htm for the form. Since the preview script is being used with the form to wizard, I don't really need it until the rest of the form loads. Another question would be, is there a cleaner way to go about using the preview script on say 10 different form inputs independently? For example in a single function rather than 10 different function/updates? I have an example of what I am trying he http://jsfiddle.net/anhyG/1/ Thank you in advance for any help! Hello again! Is there any way to pass a function(with its parameters) to another function using a parameter? Examples: Here is how I do it now: PHP Code: function output(text){ alert(text); } function bla(text, func){ output(text); } bla("Text is here", output) //Outputs "Text is here" I only want to pass the function to bla() as a parameter. I need something like this: PHP Code: function output(text){ alert(text); } function bla(func){ output(); } bla(output("Text is here")) //Outputs "Text is here" Is this possible in some way? Thanks in advance. Hi everyone, I am pretty new at javascript OOP. I have a javascript file that has plenty of javascript functions, variables, arrays, etc. I need to convert this into an object. Here is an example: Code: var myvar1 = ''; var myvar2 = new array(); var myvar3 = new array(); var myvar4; var myvar5 = 60; var myvar6 = ''; function myfunc1(){ myvar1 = 'hello'; return myvar1; } function myfunc2(somenum=0){ myvar5 = somenum; //calling myfunc1() from within this function. //do something in here } function myfunc3(){ //calling myfunc1() from within this function. for(i=0;i<somelength;i++){ myvar2 = myvar3[i]; (something to put into the array) } } 1. I need to create an object and put ALL the varibles (myvar1 - myvar5) in that object. 2. Then the first two functions "myfunc1 and myfunc2" inside the same object. 2. And the function myfunc3 needs to sit OUTSIDE my object as a regular javascript function. It calls on myfunc1 (which is inside the object) and also inserts data into myvar2 (which is classified inside the object) and myvar3 (which is classified inside the object as well). This is what i came up with, but it's not going well: Code: var myobj1 = function(){ this.myvar1 = ''; this.myvar2 = new array(); this.myvar3 = new array(); this.myvar4; this.myvar5 = 60; this.myvar6 = ''; var myfunc1 = function(){ this.myvar1 = 'hello'; return this.myvar1; } var myfunc2 = function(somenum=0;){ this.myvar5 = somenum; //calling this.myfunc1() from within this function. //do something in here } } function myfunc3(){ //calling mynewobj.myfunc1() from within this function. for(i=0;i<somelength;i++){ mynewobj.myvar2 = mynewobj.myvar3[i]; (something to put into the array) } } var mynewobj = myobj1; HELP.....!!!! i really want to get into object oriented world, so thanks in advance. (PS: I had no idea what to call this thread so, hopefully it's okay) I'm trying to make a time script for an app I'm making (this is not an HTML document; it's a .js file to be used with Titanium) however I'm having trouble getting the function to display and update. Code: function updateClock() { setInterval ( 'kiTime()', 1000 ); } function kiTime () { //Get current date and time var currentTime = new Date (); //Create variables for hours, minutes, and seconds from current time var currentHours = currentTime.getHours (); var currentMinutes = currentTime.getMinutes (); var currentSeconds = currentTime.getSeconds (); //Add a leading zero to minutes and seconds if less than ten currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes; currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds; //Create the string of time data currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds; return currentTimeString; } var win3 = Titanium.UI.createWindow({ title:'Clock', backgroundColor:'#fff' }); var tab3 = Titanium.UI.createTab({ icon:'clock.png', title:'Clock', window:win3 }); var label3 = Titanium.UI.createLabel({ color:'#999', text:updateClock(), font:{fontSize:20,fontFamily:'Helvetica Neue'}, textAlign:'center', width:'auto' }); win3.add(label3); If I use kiTime() under the text field I will get the current time (or at least the time the app was opened), however if I call updateClock() it's blank. i have an image with an onclick function and parameters 0,1 i want to change the parameters of the onclick function through the same function? Code: <img id="down0" onclick=swap(0,1) /> <javascript> function swap(a,b){ var imgda=document.getElementById('down'+a); imgda.onclick = swap(b,b+1); } </javascript> normally it should change the onclick to swap(1,2) but it remains 0,1 whats happening?? p.s. plz dont tell me about the javascript tag, its just for quick explaining... |