JavaScript - Hide Website Contents Using Java
Hi all
I have just joined the forum in hope someone could help me with a problem i am having with my Java code. This is my bit of code and I will try to explain what I want to achieve. <table width="100%" border="1" cellpadding="0" cellspacing="0"> <tr> <td width="30"><font size="-2">Day</font></td> <td width="50"><font size="-2">Period</font></td> <td width="50"><font size="-2">Time</font></td> <td width="50"><font size="-2">Total</font></td> <td width="35"><font size="-2">Code</font></td> <td><font size="-2">Note</font></td> </tr> </table> <? for ($x=1;$x<=7;$x++) { ?> <table width="100%" border="1" cellpadding="0" cellspacing="0"> <tr> <td width="30" rowspan ="8"><p align="center"><font size="-2"><? print $day[$x]?></font></p> <p align="center"><font size="-2"><? print date("dS",$week_timestamp +($x-1)*90000)?></font></p></td> <? for ($y=1;$y<=8;$y++) { $start = "start".$y; $finish="finish".$y; $code="code".$y; $note="note".$y; $total="total".$y; ?> <td width="50"><font size="-2">Start</font></td> <td width="50"> <font size="-2"> <? if (${$start}[$x] != ""){ print ${$start}[$x]; }else{ print " "; } ?> </font></td> <td width="50" rowspan ="2"><div align="center"><font size="-2"> <? print ${$total}[$x] ?><font></div></td> <td width="35" rowspan ="2"><div align="center"><font size="-2"> <? if (${$code}[$x] != ""){ print ${$code}[$x]; }else{ print " "; } ?> </font></div></td> <td rowspan ="2"> <font size="-2"> <? if (${$note}[$x] != ""){ print ${$note}[$x]; }else{ print " "; } ?></font></td> </tr> <tr> <td width="50"><font size="-2">Finish</font></td> <td width="50"> <font size="-2"> <? if (${$finish}[$x] != ""){ print ${$finish}[$x]; }else{ print " "; } ?> </font></td> </tr> <? } ?> </table> Basically this gives me a table with all the start and finish times for each day from Monday to Sunday. What I'm looking at is the ability to hide particular day using java if possible. I know you can use div's to do this and I've searched the forum for solution but it looks like my case is unusual. I wan't to use show/hide buttons to display certain day and hide rest of them. Is it possible to put the new code around the existing one? Any help would me much appreciated. If you need any more details please let me know. Thanks Similar TutorialsHi I want to get javascript to show or hide a row in a table depending on whether a value is held by a variable collected in a mulitple part formmail. If only 1 adult fills in their name on the earlier form there is no need to show the row which asks him to agree to membership on a later form page. This is what Ive got so far Code: <form name="frm3" method="post" action="bookingscript.php"> <input type="hidden" name="adult2fn" value="$adult2name" /> <script Language="JavaScript"> var name1 = document.frm3.adult2fn.value; if(name1 =="") {alert("hello");document.getElementById("hidden_row").style.display = 'none';} else {alert("no way");document.getElementById("hidden_row").style.display = '';}; </script> <table border="1"> <tr> <td>Always visible</td> </tr> <tr id="hidden_row"> <td>Hide this</td> </tr> <tr> <td>Always visible</td> </tr> </table> </form> If $adult2name is blank then name1 is blank and the row does not show, else $adult2name contains a name, name1 is not blank and the row shows. I have tried displaying the hidden form field (by changing it to text), and adding my own content, also putting in my own values instead if $adult2name and the Alerts appear as appropriate, but the whole table disappears whilst the alert is on and reappears when the alert is OKed for either condition of the if. Same in Firefox and IE7 & 8 Could someone please tell me the error of my ways. Many thanks Richard I have a form that was created in Adobe Professional. I have hidden the toolbars on initial view of the form, however, the people using the form have discovered how to un-hide them. Is there any Java Script that I can add to the document that will disable certain menu commands (i.e. "Attach to E-mail")?
Helloo Im new to javascript.. I need help badly... here are two tabless. 1. information of a friend. 2nd table i get when i click da image (ADD ANOTHER FRIEND) but, on validation and submission.. the second table is not showing upp... When i once click ADD FRIEND.. i want the table to show up on reload and validation.... Thanks Here is my code <? if (isset($_POST['submit'])) { if (!$frndname) { $frndname_error = 1; $problems=1; } if (!$frndcity) { $frndcity_error = 1; $problems=1; } ///doo db stuff insertion } ?> <!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>Untitled Document</title> <script type="text/javascript"> function showTable() { var table = document.getElementById("myTable"); if (table) table.style.display = "block"; var div = document.getElementById("frndimg"); if(div) div.style.display = "none"; } </script> </head> <body> <form action="" method="POST" name="form1"> <?php if(!isset($_POST['submit']) or $problems) { ?> <table> <tr> <td colspan="2"> <table width="21%"> <tr> <td width="3%" align="left" valign="top"> </td> <td colspan="2"> <b class="referralheading"> YOUR FRIEND'S INFORMATION: </b> </td></tr> <tr> <td width="3%" align="left" valign="top"> </td> <td width="16%"><? if ($frndname_error) { echo ("<font color='#FF0000'>Name:</font>"); } else { echo ("Name:"); }?> <b><font color="#FF0000">*</font></b><br> <input type="text" name="frndname" id ="frndname" value="<?php echo $frndname; ?>" maxlength=45 size=25></td> <td width="81%" colspan="3">City: <b><font color="#FF0000">*</font></b><br><input type="text" id="frndcity" name="frndcity" value="<?php echo $frndcity; ?>" maxlength=45 size=25> </td> </tr> </table></td></tr> <tr> <td width="4%" align="left" valign="top"> </td> <td > <div style="float:left;cursorointer;"> <img src="images/referral_add_friend.jpg" width="190" height="28" onClick="showTable()" title="Click to add another friend" id="frndimg"> </div> </td></tr> <tr> <td colspan="2"> <table width="100%" id="myTable" style="display:none;"> <tr> <td width="4%" align="left" valign="top"> </td> <td colspan="2"> <b class="referralheading"> YOUR FRIEND'S INFORMATION: </b> </td></tr> <tr> <td width="4%" align="left" valign="top"> </td> <td width="53%"> NAme: <b><font color="#FF0000">*</font></b><br> <input type="text" name="frnd1name" id ="frnd1name" value="<?php echo $frnd1name; ?>" maxlength=45 size=25></td> <td width="47%" colspan="3">City: <b></b><br><input type="text" id="frnd1city" name="frnd1city" value="<?php echo $frnd1city; ?>" maxlength=45 size=25> </td> </tr> <tr> <td width="4%" align="left" valign="top"> </td> <td>Phone Number: <b></b><br> <input type="text" name="frnd1phone" id ="frnd1phone" value="<?php echo $frnd1phone; ?>" maxlength=45 size=25></td> <td colspan="3">Email: <br><input type="text" id="frnd1email" name="frnd1email" value="<?php echo $frnd1email; ?>" maxlength=45 size=25> </td> </tr> <tr><td> </td></tr> </table> </td></tr> <tr> <td><input type="image" src="images/submit_referral.jpg" height="30" width="173" border="0" alt="Submit Form" value="submit"></td></tr> <tr><td> </td><td align="center" class="referralheading"> Fields Marked With * Are Required</td></tr> </table> <? } ?> </form> </body> </html> Hello, I have to print my cell phone call records but unfortunately my wireless provider displays the number I called only when mouse is hovered over Call details. I have 470 call records and copy pasting all those numbers when mouse is hovered over it will be one hell of a task. Is there any way I could save all the information related to Called Number and do not have to move my mouse for each and every number? Using my basic programming understanding (Though I know nothing about javascript), they are using some mouseover function that displays this information. The possibility of this information to be on the server is less because this information is even available when I switch off my wireless. I can paste that portion of the code if someone needs it to help me out. Saving this website using normal "Save as" does not save the required information. Is there any other way I can save this website will all its details or somehow disabling this mouseover function so that call details are not hidden anymore. Regards, Scoobydoo Hi, I'm currently the owner of www.sc2-strategy.com and I want to have javascript show/hide like one of my rivals www.sc2casts.com has, however I have no javascript knowledge and want to learn how to implement this, It makes the site look much more professional and allows for better user experience, sorry if it sounds like I don't know much, I'm just looking for help and since you guys have a very large active forum user base, I thought this would be the best place to ask, thanks. Btw, the javascript is basically meant to be used to display Game 1 (clicked) Youtube video displayed (hide button) Game 2 (display) Hidden Youtube Video etc. You'll be able to see what i mean if you go onto www.sc2casts.com Hi I need to produce some code to get the contents of the particular TD I am running a function in. I have the following code which works fine up the point of wanting to delete a row. In order to make it work again I have to go into the code and adjust all the numbers in the functions (not sure that's the correct terminology) Code: <head> <script language='javascript'> exchRate = '1.12'; function gettheUKP(which) { // This is the line I think I need to change var x = document.getElementsByTagName("span")[which].innerHTML; var s = Math.round(x / exchRate); document.write('(£' + s + ')') } </script> </head> <body> <table cellspacing="0" cellpadding="0" class="charges"> <tr> <td><strong><span>368</span>€</strong> <script type="text/javascript">gettheUKP(0);</script></td> </tr> <tr> <td><strong><span>471</span>€</strong> <script type="text/javascript">gettheUKP(1);</script></td> </tr> <tr> <td><strong><span>598</span>€</strong> <script type="text/javascript">gettheUKP(2);</script></td> </tr> <tr> <td><strong><span>720</span>€</strong> <script type="text/javascript">gettheUKP(3);</script></td> </tr> <tr> <td><strong><span>998</span>€</strong> <script type="text/javascript">gettheUKP(4);</script></td> </tr> </table> </body> So in essence I think I need to change the highlighted line to say "get the contents on the span within this TD". Is this possible? Thanks I'm working on stripping specific HTML tags in order to do a selected string comparison. Stripping the tag, done. Re-calibrating the selection start and end points, done. Capturing the tags for re-insertion, done. Getting the start point of the tag, done. What I am having trouble with is finding the content between the tag so that I can put it back after altering the selected text. <span class="something">find this content!</span> Any ideas are more than welcome! Thanks, Hey all, Hopefully I can explain this so it makes sense. I have a div with some buttons in it going horizontally. Kind of like a top menu of sorts. The div is of a fixed width and these buttons are spaced evenly across it. What I would like to do (and the hardest part is finding the right words for all this) is add more buttons. But because of the limited space I want to leave the current buttons as they are but provide a way, either by hovering over the left or right end of the div ideally or clicking << or >> types of links to 'cycle' through the buttons. So end result would be the user would see lets say 5 buttons upon load but be able to access the other buttons by cycling/scrolling left or right. It would be great if the buttons would loop around so they would never reach the 'end' going left or right. Does this make sense? I haven't been able to find anything close to this but that could possibly be because I am not sure what to call it. Thanks for any help! Hi.. Im currently working on my project and I have a big problem with changing the layout of tabs. Basically, when I launch my GUI, it will display "No Data Available" in my view tab. In my Add tab, I have the admin panel whereby the user enters the data to be stored and display. the problem now lies when displaying. It is a juke ringtone gallery whereby when there are data being stored in the database, it will display the following in a Gridlayout; I applied the ChangeListener to the JTabbedPane which is tp. I added tabs using tp.add. I declared this in my ChangeListener: if(tp.getSelectedIndex() == 0) createViewPanel(); else if(tp.getSelectedIndex()==1) createAddPanel(); where createViewPanel() is for the View tab and createAddPanel() is for the Add tab. i also called the respective tabs using frameView = (JPanel)tp.getComponent(0); to get the layout for View tab and frameAdd = (JPanel)tp.getComponent(1); to get the layout for the Add tab. What methods need I use so that I can display the different data in the specific GridLayout to be displayed in the View tab or what other ways can I do it? Hi, How I build a table based on a list under a <DIV></DIV> like this? printing: 1 and: 3 typesetting: 2 industry: 2 has: 2 been: 1 s: 1 standard: 1 ever: 1 since: 1 1500s: 1 when: 1 an: 1 unknown: 1 printer: 1 took: 1 a: 2 galley: 1 type: 3 scrambled: 1 Regards Bob Hi all! First post here (obviously)... I seem to have an issue with getting javascript to recognize the value of a variable. Code: for(var m=1; m<=86; m++) { var currgroup = "group" + m; alert(currgroup); if(currgroup.Contains(point)) { var userNG = m; var foundNG = true } else { var foundNG = false; } } If you see where I alert the value of currgroup, it displays "Group1" as it should... so the next line should be Group1.Contains(point); but it errors out as "currgroup.Contains(point) is not a function". If however I hard code it with Group1.Contains(point) it works fine. Is there a way to tell JS explicitly that I want it to use the variable contents instead of the name that I'm missing? Thanks a bunch for any and all help, Matt Hey. I have been pulling out my hair trying to do this. I am printing out the contents of a DIV tag but it does not print the css with it. Just the basic text For example: .testDiv { border: 1px solid #0F0; margin-right: 300px; text-decoration: underline; font-weight: bold; } The print does not change the text according to the css. Why is this? Thanks in advance for any help. Marc Hi guys I was wondering if its possible to add contents within a div to a javascript array. Something like this: Code: <script type="text/javascript"> function returnArray() { var divContent = document.getElementById('images'); var matchImage = divContent.match(/<img/); /* add images into array somehow */ alert('This is ' +ImageArray[1]); } </script> <div id="images"> <img src="image1.jpg" alt="image" /> <img src="image2.jpg" alt="image" /> <img src="image3.jpg" alt="image" /> </div> Thanks for any info. Hi friends, I am very well aware that ctrl-a and ctrl-c will not copy images (only the text) in ms-word/openoffice writer. so, the better option is to convert the doc into html and place the contents of the html in Tinymce editor. (This is what i want to accomplish). I know this thing can be done in javascript but i dont know how. Please tell me or any guidance to copy the contents of word(text and images at one go) into a tinymce editor. Any help would be highly appreciated. Thanks, aras See http://forums.mathannotated.com/gui-...-layout-4.html. When you click the "More" tab, the browser forgets the active tab styling and current tab contents; I don't want these to change - all I want to change on the click "More" tab action is the navigation tab. But my browser should maintain the styling for the last active tab and continue to display its corresponding tab contents. Yet it forgets these details when the user clicks "More". In particular, when user navigates back and forth between the two tab sets, whatever was the last styled active tab remains styled as such. Browser should remember this. Code: $(document).ready(function() { //When page loads... $(".tab_content").hide(); //Hide all content $("ul.tabs li:first").addClass("active").show(); //Activate first tab $(".tab_content:first").show(); //Show first tab content //On Click Event $("ul.tabs li").click(function() { $("ul.tabs li").removeClass("active"); //Remove any "active" class $(this).addClass("active"); //Add "active" class to selected tab $(".tab_content").hide(); //Hide all tab content var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content $(activeTab).fadeIn(); //Fade in the active ID content return false; }); //Your additions //When page loads... $("#button_set_2").hide(); //Hide 2nd button set; added by YOU //On Click Event: hide 1st button set, show 2nd $("li#more_forward").click(function() { $("#button_set_1").hide(); $("div#button_set_2").show(); }) //On Click Event: hide 2nd button set, show 1st again $("li#more_backward").click(function() { $("#button_set_2").hide(); $("div#button_set_1").show(); }) }); @ http://jsfiddle.net/defencedog/cu5VJ/ I am having problem in understanding the operation of js with regards to this line Code: $('.' + x[i].id).text(x[i].innerHTML); or Code: $('.' + x[i].id).html(x[i].innerHTML); I want to understand why I ain't able to produce desired results while using this instead Code: $('.' + x[i].id).innerHTML(x[i].innerHTML); I use a PHP page to set elements of a text file on our web server and I want to create a javascript function to intermitently check the contents of that file and if an element in that file matches a criteria I want to act on it... So, I do this <script type="text/javascript"> t = setInterval("CHECKFILE()",5000); </script> This calls the CHECKFILE function every 5000ms <script type="text/javascript"> function CHECKFILE(){ } </script> How, in the CHECKFILE function can I read from a file called FILE.txt for example?? In PHP I can use $myFile = "FILE.txt"; $theData = file($myFile); And this gives me an array, with each element containing one line from the file Can I do similar in Javascript? Or can I add PHP into the JS to do it for me? Thanks I have the following code in a website which is the W3C method of loading XML/XSL via Javascript. The code works perfectly except as you can see from the last line of code it appends the fixed div. This is not suitable as I need the site to overwrite the contents of the fixed div (not append). How could I rewrite that last line of code so that the data within the fixed div is rewritten with the contents of resultDocument. innerHTML doesn't work since the content of resultDocument is an XML file. Code: xml=loadXMLDoc("dating_database.xml"); { xsltProcessor=new XSLTProcessor(); xsltProcessor.importStylesheet(xsl); resultDocument = xsltProcessor.transformToFragment(xml,document); document.getElementById("fixed").appendChild(resultDocument); } I'm sorry this is simple, but: Code: function printInput(f){ var ifr = window.frames['printFrame']; var v1=readCookie('lesson'); if (v1==1){v2='WORKNOTEPAD1'} if (v1==2){v2='WORKNOTEPAD2'} if (ifr){ ifr.document.getElementById('content').innerHTML=f. v2 .value.replace(/\n/g,'<br />'); ifr.focus(); ifr.print(); } else { something } } In this line: Code: ifr.document.getElementById('content').innerHTML=f. v2 .value.replace(/\n/g,'<br />'); How can I make it stop erroring and act as if the "v2" were, say, "WORKNOTEPAD2"? If the line contains the string it all works fine. It must be so simple... I need to make a javascript that when I am at a page within a game I play and click the javascript, it will get the value of a table cell, separate them to x and y variables and then put the values into a link that opens. The open link is of a php script that uses $_GET for the values of the variables to query my database. I am terrible at javascript and have been trying to do this for 2 days now with no success. So I hope I can find help here. Here's the scripts so it is easier to understand: This is part of the html page that is from the game. I need to have the javascript get 432|608 and assign x=432 and y=608 in this case, although those number change, the place in the table that that they are displayed do not change. <td>Coordinates:</td> <td><a href="game.php?village=19392&s=map&x=432&y=608">432|608</a></td> <html> <head> <title></title> <meta http-equiv="Content-Language" content="de"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Page-Enter" content="revealTrans(Duration=0.1,Transition=4)"> <link rel="stylesheet" type="text/css" href="kingsage.css"> <link rel="shortcut icon" href="favicon.ico" type="image/ico"> <script src="js/kingsage.js?hash=1e4c479f8ba66202f3b1bfb74414eef4" type="text/javascript"></script> <script src="js/mootools-1.2-core-nc.js?hash=1e4c479f8ba66202f3b1bfb74414eef4" type="text/javascript"></script> <script src="js/mootools-1.2-more.js?hash=1e4c479f8ba66202f3b1bfb74414eef4" type="text/javascript"></script> <script src="js/map_src.js?hash=1e4c479f8ba66202f3b1bfb74414eef4" type="text/javascript"></script> </head> <body> <script type="text/javascript"> //<![CDATA[ lang = new Array(); lang['DAY'] = 'Day'; lang['DAYS'] = 'Days'; //]]> </script> <div style="background: rgb(0, 0, 0) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" align="center"> <table style="border-collapse: collapse; height: 100%;" width="100%" cellpadding="0" cellspacing="0"> <tbody> <tr valign="top"> <td width="50%" align="right"> <br> </td> <td style="width: 840px;"> <table style="border-collapse: collapse; width: 840px; height: 100%;" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="lay_content" valign="top"><a name="head2"></a> <div class="contentpane"> <table class="borderlist" style="width: 420px;"> <tbody> <tr> <th colspan="2">Abandoned settlement</th> </tr> <tr> <td>Coordinates:</td> <td><a href="game.php?village=19392&s=map&x=432&y=608">432|608</a></td> </tr> <tr> <td>Points:</td> <td>390</td> </tr> <tr> <td>Player:</td> <td><br> </td> </tr> <tr> <td>Alliance:</td> <td><a href="game.php?village=19392&s=info_ally&id="></a><br> </td> </tr> </tbody> </table> <br> </div> </td> </tr> </tbody> </table> </td> <td width="50%" align="left"> <br> </td> </tr> </tbody> </table> </div> <div id="settlement" style="display: none;"></div> <script type="text/javascript"> //<![CDATA[ startCounter(); //]]> </script> </body> </html> Here's the php script that will process the x and y Code: <?php putenv("TZ=Europe/Berlin"); session_start(); include("includes/config.php"); $username = $_GET['username']; $pass = $_GET['pass']; $x = $_GET['x']; $y = $_GET['y']; $now = time(); //confirm user can make claim global $conn; $q = "SELECT password FROM users WHERE username = '$username' AND active = 1"; $result = mysql_query($q,$conn); if(!$result || (mysql_numrows($result) < 1)) { $data = "Your identity can not be authenticated"; } else { $dbarray = mysql_fetch_array($result); if($pass == $dbarray['password']) { $continue = true; } else { $data = "Your password can not be authenticated"; } } //if can claim then check the village if($continue) { $q = "SELECT * FROM `claims` WHERE x = '$x' AND y = '$y' AND state = 1"; $village = mysql_query($q, $conn); $result = mysql_fetch_assoc($village); if(!$result) { $can_claim = true; } elseif($result) { if($result['username'] == $username) { $data = "You already have an active claim on ($x|$y)"; } elseif($result['username'] <> $username) { $claimer = $result['username']; $data = "$claimer already has an active claim on ($x|$y)"; } } if($can_claim == true) { global $conn; $claim_made = time(); $claim_expires = $claim_made + 432000; $state = 1; $q = "INSERT INTO `claims` (x, y, username, claim_made, claim_expires, state) VALUES ('$x', '$y', '$username', '$claim_made', '$claim_expires', '$state')"; $add_claim = mysql_query($q, $conn); if($add_claim) { $data = "Success! You claimed ($x|$y)"; } else { $data = "Error: Your claim on ($x|$y) did not complete."; } } echo "<SCRIPT>alert(\"$data\");</SCRIPT>"; } ?> The javascript should link to this php script and send the variables like this: 'http://twv-kingsage.tw-family.us/auto_add_claim.php?username=username&pass=md5_password&x="+x+"&y="+y' Can someone tell me how to extract the values for x and y from the page and get them to the link? Thanks for the help, it is much appreciated. |