JavaScript - Anchors Corelating With Javascript
Hi there!
I am pretty decent at PHP and HTML and I am slowly but surely learning Javascript, I don't really understand how Anchors work with Javascript though... If you would please help me out by pointing me in the right direction, I've seen on several occasions where Javascript will actually change text of a page depending on the selected Anchor, now I now how to make Javascript perform changes of things depending on their ids, but I do not know how it makes reference to an Anchor, could someone please be of some aid? I really appreciate it! Kind Regards Matthew Similar TutorialsHi, I've got a drop down menu that works fine except I now want to add anchor links to it so that when one clicks on an option it updates the anchor in the url, however currently whenever i click on one it says 'undefined'. Any help would be appreciated. Thanks Code: function DropDown(el) { this.dd = el; this.placeholder = this.dd.children('span'); this.opts = this.dd.find('ul.dropdown > li'); this.val = ''; this.index = -1; this.initEvents(); } DropDown.prototype = { initEvents : function() { var obj = this; obj.dd.on('click', function(event){ $(this).toggleClass('active'); return false; }); obj.opts.on('click',function(){ var opt = $(this); obj.val = opt.text(); obj.index = opt.index(); obj.placeholder.text(obj.val); var anchors = opt.text(); window.location.hash = '#'.anchors; }); }, getValue : function() { return this.val; }, getIndex : function() { return this.index; } } First, apologies I'm a newbie with javascript. Here's the problem: I have javascript in an iframe that controls showing/hiding of divs. This works great, but after the javascript is executed it changes the behavior of anchor tags of the main window of the website (namely - links in the main window all open in new windows and not in the specified target iframe). I've searched and searched and looked up all sorts of things, rendering me a confused and frustrated fellow. here's the script: <script language="javascript"> function show(thechosenone) { var newboxes = document.getElementsByTagName("div"); for(var x=0; x<newboxes.length; x++) { name = newboxes[x].getAttribute("name"); if (name == 'newboxes') { if (newboxes[x].id == thechosenone) { newboxes[x].style.display = 'block'; } else { newboxes[x].style.display = 'none'; } } } } </script> and in the body: <a id="myHeader2" href="javascript:show('myDiv');" >click here to show div</a> ANY help is greatly appreciated! Hello! I am trying to find a script that allows you to open multiple browser tabs and then close each of those tabs, either one by one or all at once. Does anyone know how to do this please? Thanks so much for your help. I want to have another go at Javascript. I have several books on the subject but I find that my eyesight is a major problem. Therefore I want to try an on-line solution, preferably free. I have Googled, but there are so many that I am almost dizzy with the choices. Perhaps someone could recommend one. Not too fussy visually. My knowledge is VERY basic. Frank Does anyone know how to make URL links that use Javascript still work when users have Javascript disabled on their browser? The only reason I'm using JS on a URL is because my link opens a PDF file, and I'm forcing it not to cache so users have the latest version. I tried the <script><noscript> tags, but I'm not sure if I'm using it correctly, as my URL completely disappears. Below is my HTML/Javascript code: <p class="download"> <script type="text/javascript">document.write("<span style=\"text-decoration: underline;\"><a href=\"javascript:void(0);\" onclick=\"window.open( 'http://www.webchild.com.au/mediakit/Direct_Media_Kit_Web.pdf?nocache='+ Math.floor( Math.random()*11 ) );\" >The Child Magazines Media Kit</a></span> (PDF 1 MB) ");</script> <noscript><span style="text-decoration: underline;"><a href="http://www.webchild.com.au/mediakit/Direct_Media_Kit_Web.pdf" >The Child Magazines Media Kit</a></span> (PDF 1 MB)</noscript> </p> Thanks for any help, Michael Hi Guys, I am new at JavaScript and start to do some tutorials.What I am trying to do here is prompting user to input a name and if the name was valid the page(document) will display with all objects like the button.But if user enter a wrong name then the button will be disabled! I create the following code but it did not work <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>New Web Project</title> <script language="JavaScript" type=""> function changeColor(){ document.bgColor = "Gray"; } </script> </head> <body> <script language="JavaScript" type="text/javascript"> var person = ""; person = prompt('What is Your Name:'); if (person == "Foo") { document.write("<h1 />Welcome " + person); document.bgColor = "Yellow"; } else { document.write("<h1 />Access Denied!!!!"); document.bgColor = "Red"; document.getElementById("gree").disabled = true; } </script> <div> <p/><input id="gree" type="button" value="Gray " onClick="changeColor();"> </div> </body> </html> as you can see I used the: document.getElementById("gree").disabled = true; but it did not work , could you please give an idea how I can solve this problem? Thanks Hi, I have the following code snippet: test.html ====== <script language="javascript" type="text/javascript"> var testVariable = "test"; </script> <script language="javascript" type="text/javascript" src="test.js"> </script> test.js ===== var testVariable = window.top.testVariable; In firefox, I'm able to access testvariable defined within test.html in test.js. But in chrome, test.js couldnot get the window.top.testVariable field defined in test.html. Can any one please let me know how i can make it work in chrome?. Am i missing something here?. I got an index.php Code: <html> <form action="bacakomik.php" method='post'> <select name="kodekomik"> <option value='../komik1/|23'>Judul Komik1</option> <option value="../komik2/|20">Judul Komik2</option> <option value="../komik3/|10">Juduk Komik3</option> <option value="../komik4/|20">Judul Komik4</option> </select> <input type="submit" /> </form> <?php echo ('<select>'); echo ('<option value= "'.$i.'">'.'Page '.$i.'</option>'); echo ('</select>'); ?> </html> As you can see, each of the option brings specific value "../komik1/|23" komik1 is a directory | is a delimiter 23 is the pages in one chapter and can be considered also as how many images are there on a specific directory This is my bacakomik.php Code: <?php $dirkomik = $_POST['kodekomik']; $exploded = explode("|", $dirkomik); echo ($exploded[0]); //picture directory echo ("<br>"); echo ($exploded[1]); //total page in the comic $pagecount = (int)$exploded[1]; //Take last posted value, process it right away echo ('<FORM name="guideform"> '); echo ('<select name="guidelinks">'); $i=1; do { echo ('<option value= "'.$i.'">'.'Page '.$i.'</option>'); $i= $i+1; }while($i <= $pagecount); //Printing option and select echo ("</select>"); ?> <input type="button" name="go" value="Go!" onClick="document.getElementById('im').src=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value+'.png';"> </FORM> <img src="img0.jpg" id="im"> With the current code on bacakomik.php, I only can change the img src of id "im" in the same directory only. What I want is that the Javascript could "add" the "$exploded[0]" variable so that the picture can be loaded from different directory. Anyone can do this? I believe that the fix should be somewhere on input tag inside OnClick, or do you know where? Anyway, I found this on the net http://p2p.wrox.com/php-faqs/11606-q...avascript.html Please help me to those who can... Hi Guys I am trying to modify the functionality of my page. I want to be able to activate this piece of code using another javascript function. This is the code I want to activate: Code: <script type="text/javascript"><!-- $('#button-cart').bind('click', function() { $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea, .date_data input[type=\'text\']'), dataType: 'json', success: function(json) { $('.success, .warning, .attention, information, .error').remove(); if (json['error']) { if (json['error']['warning']) { $('#notification').html('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>'); $('.warning').fadeIn('slow'); } for (i in json['error']) { $('#option-' + i).after('<span class="error">' + json['error'][i] + '</span>'); } } if (json['success']) { $('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>'); $('.success').fadeIn('slow'); $('#cart_total').html(json['total']); $('html, body').animate({ scrollTop: 0 }, 'slow'); } } }); }); //--></script> And this is how I want the format of the function to be: function testsession() { if there is a session called 'hiredate' { activate the script above } else { var el = document.getElementById("product_data"); } } I just dont know how to write this in javascript Could you help me if possible please I want to insert this js snippet Code: function addText(smiley) { document.getElementById('message').value += " " + smiley + " "; document.getElementById('message').focus(); return false; } to a loaded iframe with name&id chtifrm. I can access it & change embed something in its html via using something like: Code: $(parent.chtifrm.document.body).append('<div id=\"smly\" style=\"cursor:pointer;float:left;top:200px;display:none;position:absolute;\"><\/div>'); .... Code: parent.chtifrm.document.getElementById('chatbox_option_disco').style.display == 'none' but how do I insert js in the head of loaded iframe? Hey, I've got to make the values of some textboxes change the co-ordinates of my sprite on a canvas and havent a clue on how to do it, Here is my form with the two textboxes and submit button: <form> x: <input type="text" name="x" /><br /> y: <input type="text" name:"y" /><br /> <input type="submit" value="Submit"/><br /> </form> And i need it so that they change the values of these: //this shows where my sprite will start on the canvas var block_x; var block_y; searched the internet for hours and cant really find anything i understand or works. any help is much appreciated All -- I have a JavaScript config file called gameSetting.js which contains a bunch of variables which configures a particular game. I also have a shared JavaScript library which uses the variables in gameSetting.js, which I include like so: <script type="text/javascript" src="gameSetting.js" ></script> <script type="text/javascript" src="gameLibrary.js" ></script> In gameSetting.js I have: $(document).ready(function() { // call some functions / classes in gameLibrary.js } in Firefox, Safari, and Chrome, this works fine. However, in IE, when it's parsing gameSetting.js, it complains that the functions that live in gameLibrary.js aren't defined. When it gets to parsing gameLibrary.js, the variables in gameSetting.js are reported as not being defined. I've tried dynamically bootstrapping the gameLibrary file using this function in document.ready for dynamic load... $.getScript("gameLibrary.js"); However, the same problem still happens in IE, where when it parses the files individually it's not taking into context the file/variables that came before, so it's not an out of load order problem. My options a 1) collapsing all the functions in gameLibrary.js and variables in gameSetting.js into one file. However, this is not practical because this is dealing with literally hundreds of games, and having a gameLibrary.js in ONE location for ONE update is what makes most logical sense. 2) figure out a way to get this to work where variables in file1 are accessible to file2 in IE (as it seems they are in other browsers). jQuery seems to be able to have multiple plugins that all refer to the based jQuery-1.3.2.js, so I know there is a way to get this to work. Help appreciated. Nero I wrote a log function that took note of various function calls. Thinking that functions are first class objects, and objects have properties, I made the name of each logged function a property of that function, e.g., brightenInnerPara.name = "brightenInnerPara"; Every browser I tried (Firefox, MSIE, Opera, Chrome, Safari) accepted the assignment, no problem. In Firefox and MSIE, the result was what I wanted: brightenInnerPara.name == "brightenInnerPara" But in the others, the result was: brightenInnerPara.name == null Question 1. Which Javascript is correct here? I favor Firefox and MSIE, not merely because they were willing to give me what I wanted, but also because it makes no sense to accept an assignment statement without throwing an error and then give it a null semantics, like Chrome, Opera, and Safari did. I found a workaround, using assignments like this: brightenInnerPara.prototype.name = "brightenInnerPara"; To my surprise, that worked in every browser. But I don't know why. It seems that such assignments are enough to cause each function to have its own distinct prototype. Question 2. Just how inefficient is my workaround, and why does it work? I need some help with this Code. I can't seem to get it to go to the page I want it to. You can make a dummy page for example Page 1.html to see if it works for ya. Thanks Code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta name="generator" content= "HTML Tidy for Linux/x86 (vers 11 February 2007), see www.w3.org"> <title>Calculate Groom's Dowry</title> </head> <body> <center> <i><font size="6"><b>Groom's Dowry Rate Calculator*</b></font> </i> </center><br> <br> <br> <br> <i>*Dedicated to all the match making aunties of India</i> <center> <b>Groom's Age</b> </center> <form name="Age" id="Age"> <center> <select name="Groom’s Age"> <option value="a1"> Select </option> <option value="a2"> 23 </option> <option value="a3"> 24 </option> <option value="a4"> 25 </option> <option value="a5"> 26 </option> <option value="a6"> 27 </option> <option value="a7"> 28 </option> <option value="a8"> 29 </option> <option value="a9"> 30 </option> <option value="a10"> 31-35 </option> <option value="a11"> 36-40 </option> <option value="a12"> 41-45 </option> <option value="a13"> 46-50 </option> <option value="a14"> 51+ </option> </select> </center> </form><br> <b>Groom's Caste</b><br> <form name="Caste" id="Caste"> <select name="Groom’s Caste"> <option value="b1"> Select </option> <option value="b2"> Brahmin </option> <option value="b3"> Bania </option> <option value="b4"> Kayastha </option> <option value="b5"> Kshatriya </option> <option value="b6"> Dalit </option> <option value="b7"> Maravar </option> <option value="b8"> Mudaliar </option> <option value="b9"> Nair </option> <option value="b10"> Jat </option> <option value="b11"> Labanas </option> <option value="b12"> Rajput </option> </select> </form><b>Groom's current Profession</b> <form name="Profession" id="Profession"> <select name="Groom’s Profession"> <option value="c1"> Select </option> <option value="c2"> Doctor </option> <option value="c3"> Engineer </option> <option value="c4"> Lawyer </option> <option value="c5"> CA </option> <option value="c6"> IAS </option> <option value="c7"> Engineer + MBA </option> <option value="c8"> Family Business </option> <option value="c9"> None of the above </option> </select> </form><b>Groom's Degree at the Bachelor's Level</b> <form name="Bachelor" id="Bachelor"> <select name="Groom’s Bachelor"> <option value="d1"> Select </option> <option value="d2"> BTech/BE/BS </option> <option value="d3"> MBBS </option> <option value="d4"> BA </option> <option value="d5"> B.Com </option> <option value="d6"> B.Ed </option> <option value="d7"> Bsc </option> <option value="d8"> BBA </option> <option value="d9"> Diploma </option> <option value="d10"> Certification Course </option> </select> </form><b>Groom's Degree at the Master's Level</b> <form name="Master" id="Master"> <select name="Groom’s Master"> <option value="e1"> Select </option> <option value="e2"> MBA </option> <option value="e3"> MS </option> <option value="e4"> MTech </option> <option value="e5"> MPhil </option> <option value="e6"> M.Ed </option> <option value="e7"> MHA </option> <option value="e8"> No Master's degree </option> </select> </form><b>Groom's Degree at the Doctorate Level</b> <form name="Doc" id="Doc"> <select name="Groom’s Doc"> <option value="f1"> Select </option> <option value="f2"> Doctor of Philosophy (Phd) </option> <option value="f3"> Doctor of Medicine (MD) </option> <option value="f4"> No Doctorate Degree </option> </select> </form><b>The Groom is working in</b> <form name="Country" id="Country"> <select name="Groom’s Country"> <option value="g1"> Select </option> <option value="g2"> India </option> <option value="g3"> USA </option> <option value="g4"> Any European Country </option> <option value="g5"> Australia </option> <option value="g6"> Canada </option> <option value="g7"> Any Country more developed than India </option> <option value="g8"> Any Country less developed than India </option> </select> </form><b>Groom's Skin Color</b> <form name="Color" id="Color"> <select name="Groom’s Color"> <option value="h1"> Select </option> <option value="h2"> Fairy White </option> <option value="h3"> White </option> <option value="h4"> Wheatish (Almost White. Would need some Fair n Lovely) </option> <option value="h5"> Brown </option> <option value="h6"> Black </option> <option value="h7"> Pitch Black (Not visible on a moonless night) </option> </select> </form><b>Groom's Height</b> <form name="Height" id="Height"> <select name="Groom’s Height"> <option value="i1"> Select </option> <option value="i2"> Less than 5'4" </option> <option value="i3"> 5'5" </option> <option value="i4"> 5'6" </option> <option value="i5"> 5' 7" </option> <option value="i6"> 5'8" </option> <option value="i7"> 5'9" </option> <option value="i8"> 5' 10" </option> <option value="i9"> 5'11" </option> <option value="i10"> 6' </option> <option value="i11"> 6'1" </option> <option value="i12"> Greater than 6'1" </option> </select> </form><b>Number of times the Groom has married before</b> <form name="Marriage" id="Marriage"> <select name="Groom’s Marriage"> <option value="j1"> Select </option> <option value="j2"> 0 </option> <option value="j3"> 1 </option> <option value="j4"> 2 </option> <option value="j5"> More than 2 </option> </select> </form><b>What is Groom's father's profession</b> <form name="Father" id="Father"> <select name="Groom’s Father"> <option value="k1"> Select </option> <option value="k2"> Engineer </option> <option value="k3"> Doctor </option> <option value="k4"> IAS </option> <option value="k5"> Lawyer </option> <option value="k6"> CA </option> <option value="k7"> IAS </option> <option value="k8"> Engineer + MBA </option> <option value="k9"> Family Business </option> <option value="k10"> None of the above </option> </select> </form><script type="text/javascript"> function Selected_Age(Age) { var myindex = Age.selectedindex; var sel_groom_age = Age.options[myindex].text; return sel_groom_age; } </script> <script type="text/javascript"> function Selected_Caste(Caste) { var myindex_1 = Caste.selectedindex; var sel_groom_caste = Caste.options[myindex_1].text; return sel_groom_caste; } </script> <script type="text/javascript"> function Selected_profession(Profession) { var myindex_2 = Profession.selectedindex; var sel_groom_profession = Profession.options[myindex_2].text; return sel_groom_profession; } </script> <script type="text/javascript"> function Selected_Bachelor(Bachelor) { var myindex_3 = Bachelor.selectedindex; var sel_groom_bachelor = Bachelor.options[myindex_3].text; return sel_groom_bachelor; } </script> <script type="text/javascript"> function Selected_Master(Master) { var myindex_4 = Master.selectedindex; var sel_groom_master = Master.options[myindex_4].text; return sel_groom_master; } </script> <script type="text/javascript"> function Selected_Doc(Doc) { var myindex_5 = Doc.selectedindex; var sel_groom_doc = Doc.options[myindex_5].text; return sel_groom_doc; } </script> <script type="text/javascript"> function Selected_country(Country) { var myindex_6 = Country.selectedindex; var sel_groom_country = Country.options[myindex_6].text; return sel_groom_country; } </script> <script type="text/javascript"> function Selected_color(Color) { var myindex_7 = Color.selectedindex; var sel_groom_color = Color.options[myindex_7].text; return sel_groom_color; } </script> <script type="text/javascript"> function Selected_height(Height) { var myindex_8 = Height.selectedindex; var sel_groom_height = Height.options[myindex_8].text; return sel_groom_height; } </script> <script type="text/javascript"> function Selected_married(Marriage) { var myindex_9 = Marriage.selectedindex; var sel_groom_married = Marriage.options[myindex_9].text; return sel_groom_married; } </script> <script type="text/javascript"> function Selected_father(Father) { var myindex_10 = Father.selectedindex; var sel_groom_father = Father.options[myindex_10].text; return sel_groom_father; } </script> <script type="text/javascript"> var age; var sel_groom_age_1 = function Selected_Age(Age) switch(sel_groom_age_1) { case '23': age = 1.6; break; case '24': age = 1.8; break; case '25': age = 1.7; break; case '26': age = 1.8; break; case '27': age = 1.9; break; case '28': age = 1.75; break; case '29': age = 1.7; break; case '30': age = 1.4; break; case '31-35': age = 1.8; break; case '36-40': age = 1.9; break; case '41-45': age = 1.75; break; case '46-50': age = 1.7; break; case '51+': age = 1.4; break; default: alert ('Please select an option'); } </script> <script type="text/javascript"> var caste; var sel_groom_caste_1 = function Selected_Caste(Caste) switch(sel_groom_caste_1) { case 'Brahmin' : caste = 2.0; break; case 'Bania': caste = 1.8; break; case 'Kayastha' : caste = 1.6; break; case 'Kshatriya' : caste = 2.0; break; case 'Dalit': caste = 1.8; break; case 'Maravar' : caste = 1.6; break; case 'Mudaliar' : caste = 2.0; break; case 'Jat': caste = 1.8; break; case 'Labanas' : caste = 1.6; break; case 'Rajput' : caste = 1.6; break; default : alert ('Please select an option'); } </script> <script type="text/javascript"> var profession; var sel_groom_profession_1 = function Selected_Profession(Profession) switch(sel_groom_profession_1) { case 'Engineer': profession = 1.8; break; case 'Doctor': profession = 1.9; break; case 'Lawyer': profession = 1.65; break; case 'CA' : profession = 1.7; break; case 'IAS': profession = 2.0; break; case 'Family Business': profession = 1.5; break; case 'MBA + Engineer': profession = 1.95; default:alert ('Please select an option'); } </script> <script type="text/javascript"> var bachelor; var sel_groom_bachelor_1 = function Selected_Bachelor(Bachelor) switch(sel_groom_bachelor_1) { case 'BTech/BE/BS': bachelor = 1.8; break; case 'MBBS': bachelor = 1.9; break; case 'BA' : bachelor = 1.1; break; case 'B.Com' : bachelor = 1.4; break; case 'BSc': bachelor = 1.9; break; case 'BBA' : bachelor = 1.1; break; case 'Diploma' : bachelor = 1.4; break; case 'Certification Course' : bachelor = 1.4; break; default:alert ('Please select an option'); } </script> <script type="text/javascript"> var master; var sel_groom_master_1 = function Selected_Master(Master) switch(sel_groom_master_1) { case 'MS' : master = 1.9; break; case 'MBA' : master = 2.0; break; case 'MHA' : master = 1.4; break; case 'MTech' : master = 1.4; break; case 'M.Ed' : master = 1.4; break; case 'No Master’s degree' : master = 1.4; break; default:alert ('Please select an option'); } </script> <script type="text/javascript"> var doc; var sel_groom_doc_1 = function Selected_Doctor(Doc) switch(sel_groom_doc_1) { case 'Doctor of Philosophy (Phd) ' : doc = 2.0; break; case 'Doctor of Medicine (MD)' : doc = 2.0; break; case 'No Doctorate degree' : doc = 1.4; break; default:alert ('Please select an option'); } </script> <script type="text/javascript"> var country; var sel_groom_country_1 = function Selected_Country(Country) switch(sel_groom_country_1) { case 'India': country = 1.9; break; case 'USA' : country = 2.0; break; case 'Any European Country ': country = 1.7; break; case 'Australia ': country = 1.7; break; case 'Canada ': country = 1.7; break; case 'Any Country more developed than India ': country = 1.7; break; case 'Any Country less developed than India ': country = 1.2; break; default:alert ('Please select an option'); } </script> <script type="text/javascript"> var color; var sel_groom_color_1 = function Selected_Color(Color) switch(sel_groom_color_1) { case 'Fairy White' : color = 1.9; break; case 'Black': color= 0.6; break; case 'Wheatish (Almost White. Would need some Fair n Lovely) ': color= 1.4; break; case 'Brown': color= 1.4; break; case 'White': color= 1.9; break; case 'Pitch Black (Not visible on a moonless night) ': color= 0.6; break; default:alert ('Please select an option'); } </script> <script type="text/javascript"> var height; var sel_groom_height_1 = function Selected_Height(Height) switch(sel_groom_height_1) { case 'Less than 5'4"' : height = 0.6; break; case '5'4"' : height = 0.6; break; case '5'5"' :height = 0.8; break; case '5'6"' :height = 1.0; break; case '5'7"' :height = 1.4; break; case '5'8"' :height = 1.5; break; case '5'9"' :height = 1.6; break; case '5'10"' :height = 1.7; break; case '5'11"' :height = 1.8; break; case '6' :height = 1.85; break; case '6'1"' :height = 1.9; break; case 'Greater than 6'1"' :height = 1.8; break; default:alert ('Please select an option'); } </script> <script type="text/javascript"> var marriage; var sel_groom_marriage_1 = function Selected_Marriage(Marriage) switch(sel_groom_marriage_1) { case '0': marriage = 1.8; break; case '1' :marriage = 0.7; break; case '2': marriage = 0.4; break; case 'More than 2' : marriage = 0.2; break; default:alert ('Please select an option'); } </script> <script type="text/javascript"> var father; var sel_groom_father_1 = function Selected_Father(Father) switch(sel_groom_father) { case 'Doctor': father= 1.8; break; case 'IAS': father = 2.0; break; case 'Engineer': father= 1.7; break; case 'Lawyer': father= 1.65; break; case 'CA': father= 1.8; break; case 'Engineer + MBA': father= 1.9; break; case 'Family Business': father= 1.2; break; default : alert ('Please select an option'); } </script> <script type="text/javascript"> var total = age + caste + bachelor + master + doc + color + profession + father + marriage + height + country; var pageNumber = Math.floor((20 - total) / 2 + 1); if (pageNumber == 1) { window.location="Page 1.html"; } else if (pageNumber == 2) { window.location="Page 2.html"; } else if (pageNumber == 3) { window.location="Page 3.html"; } else if (pageNumber == 4) { window.location="Page 4.html"; } else if (pageNumber == 5) { window.location="Page 5.html"; } else if (pageNumber == 6) { window.location="Page 6.html"; } else if (pageNumber == 7) { window.location="Page 7.html"; } else if (pageNumber == 8) { window.location="Page 8.html"; } else if (pageNumber == 9) { window.location="Page 9.html"; } else if (pageNumber == 10) { window.location="Page 10.html"; } else { window.location="Page 11.html"; } </script> <form> <input type="submit" value="Calculate"> </form> <br> <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="Plebeian42">Tweet</a><script type="text/javascript" src= "http://platform.twitter.com/widgets.js"> </script><br> <div style="float: center; padding: 4px;"> <a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php" id= "fb_share">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"> </script> </div><br> <br> <iframe src= "http://www.facebook.com/plugins/like.php?href&layout=standard&show_faces=true&width=450&action=like&font&colorscheme=light&height=80" scrolling="no" frameborder="0" style= "border:none; overflow:hidden; width:450px; height:80px;" allowtransparency= "true"></iframe> <center> ©Creator Name </center><a rel="license" href= "http://creativecommons.org/licenses/by-nc-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src= "http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png"></a><br> This work is licensed under a <a rel="license" href= "http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License</a>. </body> </html> I am trying to create a banner where an images changes when a user refresh a page. This is the js I am using: Quote: // JavaScript Document <!-- TWO STEPS TO INSTALL RANDOM IMAGE: /* 1. Copy the coding into the HEAD of your HTML document 2. Add the last code into the BODY of your HTML document --> <!-- STEP ONE: Paste this code into the HEAD of your HTML document --> */ //<SCRIPT LANGUAGE="JavaScript"> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Begin // Set up the image files to be used. var theImages = new Array() // do not change this // To add more image files, continue with the // pattern below, adding to the array. theImages[0] = "C:\Documents and Settings\ahadali\Desktop\website\images\head_1.jpeg" theImages[1] = "C:\Documents and Settings\ahadali\Desktop\website\images\head_2.jpeg" theImages[2] = "C:\Documents and Settings\ahadali\Desktop\website\images\head_3.jpeg" //theImages[3] = '4.gif' // do not edit anything below this line var j = 0 var p = theImages.length; var preBuffer = new Array() for (i = 0; i < p; i++){ preBuffer[i] = new Image() preBuffer[i].src = theImages[i] } var whichImage = Math.round(Math.random()*(p-1)); function showImage(){ document.write('<img src="'+theImages[whichImage]+'">'); } // End --> This is what I have in <head> Quote: <script src="banner.js" type="text/javascript"></script> This is what I have in <body> Quote: <div> <script language="javascript">showImage();</script> </div> The banner is not working. All the help is appreciated. Thanks, Ali. I need to stop my mootools ticker if its opened within cms which is simplecms. I have done this before using jquery $(document).ready(function () { if ($('meta[name = "in-cms"]').size() > 0) { // your code here //stop current animation ticker.children().stop(); } but i cannot use jquery on this piece i have tried var metas = document.getElementsByTagName('META'); var i; for (i = 0; i < metas.length; i++) alert(metas[i].getAttribute('NAME')); if (metas[i].getAttribute('name') == "in-cms"){ hor.pause(); } but it doesnt work it picks up null on meta names... I know some jquery but not what it does in the background javascript derr please help me Help, replace Double with, Quote backlash and double quote. Code: <script language="javascript"> function replace() { // // replace (" Double Quote) with (\") -backlash and double quote var str = frmEditHTML.tarHTMLText.value; str = str.replace('"', '\'') Javascript 'ERROR'... code stops here... // I know that str = str.replace('"', '\'') should work as a javascript \" ignore double quotes with the // backlash but the output does not show that \" it looks like " instead. /// str = str.replace('"', '\"') did'nt work /// frmEditHTML.tarHTMLText.value - needs .. /// to look like .. /// \"Good Morning\" \"Good Afternoon\" \"Good evening\" /// ????? /// since I will be loading a large file into <Textarea ...frmEditHTML.tarHTMLText.value //// I need this replace for that?.. // when do update the changes back to frmEditHTML.tarHTMLText.value frmEditHTML.tarHTMLText.value=str; } </script> <BR> <button onclick="replace()">Reaplace</Button> <form name="frmEditHTML"> <textarea name="tarHTMLText" cols=60 rows=10 style="color: BLUE; background-color: #E8E8E8"> "Good Morning" "Good Afternoon" "Good evening" </textarea> </form> Thank You! Please tell me a few good situations were the OO approach is the best techinque to use...
Hello friends, I need a help in HTML and java script I want that whenever i scroll the HTML page downwards then when i reaches at the bottom of the page then some event should get fired or some action should get performed like twitter I don't understand, how can i do that ? Hi there, I am trying to make a Google Map that has markers on it which when clicked display a users latest tweet. I have used the code found here to generate the latest tweet for a single user. But as this map will have multiple points of user submitted data I need something that can display multiple user tweets. So far, the user clicks on the map and enters their details, their name should be their twitter username. The data is saved to an xml file. At the moment the code is set up so that when you click on a marker it just displays your username and address. But I want to somehow include the PHP to show the users latest tweet. Here is the Javascript: Code: function readData() { var request = GXmlHttp.create(); request.open("GET", "http://mydomainname.com/test/phpsqlinfo_result.php", true); request.onreadystatechange = function() { if (request.readyState == 4) { var xmlDoc = GXml.parse(request.responseText); // obtain the array of markers and loop through it i=[0]; markers=[0]; map.getInfoWindow().hide(); gmarkers = []; map.clearOverlays(); side_bar_html = ""; var markers = xmlDoc.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { // obtain the attribues of each marker var lat = parseFloat(markers[i].getAttribute("lat")); var lng = parseFloat(markers[i].getAttribute("lng")); var point = new GLatLng(lat,lng); var label = markers[i].getAttribute("name"); var address = markers[i].getAttribute("address"); var type = markers[i].getAttribute("type"); var html = label + '<br />' + address + '<br />' + type; // create the marker var marker = createMarker(point,label,html); map.addOverlay(marker); } // put the assembled side_bar_html contents into the side_bar div document.getElementById("side_bar").innerHTML = side_bar_html; } } request.send(null); } readData(); And here is the PHP: Code: <?php function getTwitterStatus($userid){ $url = "http://twitter.com/statuses/user_timeline/$userid.xml?count=1"; $xml = simplexml_load_file($url) or die("could not connect"); foreach($xml->status as $status){ $text = $status->text; } echo $text; } //insert user id where it says userid getTwitterStatus(userid); ?> In the Javascript is there a way to include the PHP code, and in the PHP is there a way to include the variable "label" (which is declared in the javascript" where it says user id in "getTwitterStatus(userid)? I'm quite new to all this, so any help would be really appreciated! |