JavaScript - Php To Map Creation Via Javascript
Hi,
I know that it is possible to create map via javascript, which has some spots used like links. I have 3 images: background, house and man. Also 3 php variables: $man = 'yes'; $background = 'yes'; $house = 'no'; What I need is to make javascript map which would show background(yes) and man (yes). House must be invisible, because I have NO. The problem, that man must appear to 21px width 100px height and be active as a link. If you haven't understood what I want - ask. Now I will try to explain this with example. You have a map with countries. But map is like image and you can't do anything. If variable with country gets value "yes" - the country become active on the map and you can push on it. Thanks in advance... Similar TutorialsHi Here's what I want: A bracket/tournament creator on my website, so that users can start their own matches and just use my site as "scorekeeper". Here's what I've come up with so far: http://javascript.internet.com/misce...ournament.html provides a basic sketch of what I'm looking for. Can that script be changed so that multiple tournaments/matches can run at the same time. Is it also possible to only allow the participents of that specific tournament to submit the score? I'd really appreciate any help. I'll also be willing to acknowledge whatever help I get on my site, so that you can link to it, if someone wants to see your work. Thanks in advance! Hello, 1. I have the following script: function selectThis(id){ var locationstring = "process.php?value=" + id; ///// locationstring += "&bs=" + $('#bs_' + id).attr("selectedIndex"); locationstring += "&ad=" + $('#ad_' + id).attr("selectedIndex"); locationstring += "&ns=" + $('#ns_' + id).attr("selectedIndex"); locationstring += "&wt=" + $('#wt_' + id).attr("selectedIndex"); locationstring += "&in=" + $('#in_' + id).attr("selectedIndex"); document.location.href = locationstring; } With it I am getting a string with the value of the clicked button from an array and some other select field values that are listed in the same set of mysql results as the clicked button. BUTTON: <input name="button" type="button" onclick="selectThis('<? echo $rows['id']; ?>');" value=""> At the end of the script the page is redirected to in the script mentioned page with following string: process.php?value=1&bs=2&ad=3&ns=4&wt=5&in=6 (values are not real, so whatever the chosen value of the select field should apear in the link.) THIS WORKS FINE. 2. My problem is following: In order to be able to use var locationstring in other scripts as well I have removed var and have made it global. function selectThis(id){ locationstring = "process.php?value=" + id; ///// locationstring += "&bs=" + $('#bs_' + id).attr("selectedIndex"); locationstring += "&ad=" + $('#ad_' + id).attr("selectedIndex"); locationstring += "&ns=" + $('#ns_' + id).attr("selectedIndex"); locationstring += "&wt=" + $('#wt_' + id).attr("selectedIndex"); locationstring += "&in=" + $('#in_' + id).attr("selectedIndex"); } The problem is that later on when I use locationstring variable in other script I get only first variable in the string process.php?value=1 instead of process.php?value=1&bs=2&ad=3&ns=4&wt=5&in=6 3. Is it possible to make locationstring variable global and in a single line in order to be able to use the full string in other scripts or is there another solution. Thank in advance. hi, I want to create a litebox with one or two inputs in it and submit button. These inputs would work in jQuerry to update information in main page.. I see many websites are using them, but i am not so good in javascript if you know any examples of simple litebox which could work with jQuerry, please inform me. All suggestions are welcome. Kind regards, Aurimas. I want to create an array of 1 - X (X could be 10, 20, 30 or any number) Then I want to randomly choose a number from 1 - X I now want to remove the random choice - and then do the same again twice Question 1: How do I create the array in the first place? Answer: var x=[0,1,2,3,4,5,6,7,8,9,10]; I'd much prefer it if I could do something like this: var x=[0...10]; This would create the same, except, I don't have to type out all the numbers! And if I needed to increase the number in the array, I could simply just change the last number I've just made the syntax up I was hoping something similar shorthand existed Or do I have to do this by creating a loop? Question 2: how do I pop an item from the middle or somewhere other than the beginning or end? I've googled and all I can find is how to remove the first and last items! The way I see it: - Get a solution for popping from the middle of an array I'm sure I'll find a solution to this if I looked - but is it optimal to be doing it this way? - Instead, maybe I could fill my array in a random order in the first place - and then just pop at the beginning or end?? Which is the best solution? Any code to start me off would be great Thanks OM Hi! I have encountered a problem with IE that I'm simply unable to solve. I have a form where the user can choose different things to input from a drop down list and depending on the choise, different kinds of textboxes of text areas etc. are loaded onto the page with JS. After the user has finished inputing text and submits the form, I read the input with PHP and process it further. Now, this works perfectly in firefox but IE doesn't seem to add the name properties to the elements (both textboxes and text areas) because PHP cannot find them and no info is printed from the input. The creation of the elements (adding them to the page...) works just fine, it's just getting the data from them that's the problem. Since it works in FF I know it's not a PHP problem. I've used the recommended .name to set the property (although I've also tried .setAttribute() etc), yet it still doesn't work. What can I do to solve this? My relevant JS code: Code: function addTextbox(idName, head) { var target = document.getElementById('addThings'); var newDiv = document.createElement("div"); newDiv.id = "container"; newDiv.name = "container"; newDiv.setAttribute("className", "intNew"); //IE newDiv.setAttribute("class", "intNew"); //FF var newTextbox = document.createElement("input"); newTextbox.type = "text"; newTextbox.id = idName; //-- newTextbox.name = idName; //Doesn't work in IE?.. newTextbox.setAttribute("className", "newWidth"); //IE newTextbox.setAttribute("class", "newWidth"); //FF var text = document.createTextNode(head + ":"); target.appendChild(newDiv); newDiv.appendChild(text); newDiv.innerHTML += "<br />"; newDiv.appendChild(newTextbox); newDiv.innerHTML += "<p />"; } (The text area function is the same, more or less) The PHP code, if anyone's interested: Code: if($_POST['createBtn']) { $head = $_POST['head']; //1 $intro = $_POST['intro']; //2 $question = $_POST['question']; //3 $answer = $_POST['answer']; //3 $image = $_POST['image']; //? $author = $_POST['author']; //5 $end = $_POST['end']; //4 //sammanfattning printHTMLTop(9); $today = date('Y-m-d'); $text = <<<END <div class="intContainer"> <div class="intHeadRow"><b>$head </b></div> <div class="stpdIEContainer"> <div class="intTextContainer"> <p /> $intro <p /> END; if($question != "" && answer != "") { foreach($question as $k) { $text .= $k . "<p />"; foreach($answer as $j) { $text .= $j . "<p />"; } } } $text .= <<<END <p /> $end <p /> <i>Skrivet av: $author den $today</i> </div> <!-- intTextContainer --> <div class="intImgContainer"> </div></div> <!-- stpdIEContainer --> </div> <!-- intContainer --> END; //Prints to new file (on server) $file = file_put_contents('interviews/interview01.html', $text); //Set name //Add to DB //print newly created file $page = file_get_contents('interviews/interview01.html'); echo $page; printHTMLBottom(); 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 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. 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, 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?. 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 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 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 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... 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? 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? Hi guy's Not sure if what i want to do is possible, i am a very basic computer user and any help would be great. i have a relay that is conect to my router and if i type the following into the address bar it turns it on for 2 seconds. "http://192.168.1.68/state.xml?relayState=2" What i would love to do is be able to add a book mark which once selected it fires off the above string and closes the window without a prompt, is this possible??? i have spent hours and hours and seem to be going nowhere. Thanks for all your help Daniel Hi everyone, I'm trying to generate a drop down list using a supplied xml form with an xsl sheet. Because xsl lacks commands that will allow me to create repetitive <options> I am using javascript. A sample xml file that I am using is bellow. Code: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="a.xsl"?> <Country> <California> <County>San Diego</County> <County>Los Angeles</County> </California> <Nevada> <County>Reno</County> <County>Las Vegas</County> </Nevada> </Country> The xsl file that I'm using is show below. Code: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <head></head> <body> <p>This loaded</p> <form> <select name='County'> <script type="text/javascript"> var i=3; while(i > 0){ document.write("<option><xsl:value-of select='Country/California/County["); document.write(2); document.write("]'/></option>"); i--; } </script> </select> </form> <script type="text/javascript"> var i=3; while(i > 0){ document.write("<xsl:value-of select='Country/California/County["); document.write(2); document.write("]' /> <br />"); document.write("<xsl:value-of select='Country/California/County[2]'/><br />"); i--; } </script> </body> </html> </xsl:template> </xsl:stylesheet> Bassically all I'm trying to do is list the counties under california. My problem is that the javascript will print the list no problem but it only prints san diego even if my xpath index = i, is set to two. When i is set to 2, it should display Los Angeles. The following sample code will display Los Angeles Code: document.write("<xsl:value-of select='Country/California/County[2]' />"); However when the document has i = 1, it should display san diego. Unfortunately when i use i = 2 and write ... Code: document.write("<xsl:value-of select='Country/California/County[" document.write(i); document.write("]' />"); or even Code: document.write("<xsl:value-of select='Country/California/County["); document.write(2); document.write("]' />"); The xsl sheet will display san diego instead. If the code is used without brackets you can see that everything is being displayed correctly ... for instance writting Code: document.write("xsl:value-of select='Country/California/County[" document.write(i); document.write("]' /"); will result in .. Code: xsl:value-of select='Country/California/County[2]' / Why is xsl doing this to me? Hi guys, i tried searching for solutions regarding an issue i'm facing but i can't seem to understand what others are asking or the solutions given. I'm not sure if its because our codes are different or what. Basically the problem i'm facing is that i'm trying to allow user to login to my website using facebook, i'm able to retrieve user's facebook username n information but i'm unable to extract them into my php file as the codes are within a script as shown. <script> FB.init({ appId:'app_id', cookie:true, status:true, xfbml:true }); FB.api('/me', function(user) { if(user != null) { var image = document.getElementById('image'); image.src = 'http://graph.facebook.com/' + user.id + '/picture'; var name = document.getElementById('name'); name.innerHTML = user.name //document.getElementById('username').innerHTML = user.username; var username = document.getElementById('username'); username.innerHTML = user.username } }); </script> <fb:login-button perms="email"> Login with Facebook </fb:login-button> <div align="left"> <img id="image"/> <div id="name"></div> <div id="username"></div> </div> I'm able to get the user's username using 'user.username' within the script but i'm unable to save it in my php login page which i'm gonna use it to store into my database. From my understanding this can be done either using cookie or a hidden field but i'm not sure how to integrate them into my code. Hope there's some pros here who can help this noob.. =[ I'm new and am not sure if this is the right section but this was my assignment for my intro to programming class. I was absent the day of the lesson and didn't understand much, so this is what I have. jsfiddle I don't know how to put more than one phrase in the alert box, how to keep a running total of the numbers entered & I can't seem to get a counter to work on the second button. Please and Thank you for any help. |