JavaScript - Javascript Getting Replaced.
Hello guys,
This problem I've had for nearly 2 weeks now because of it I cannot progress any deeper with my project. Here is a live demo http://dcourt.zxq.net/dcourt/ try to login pkedpker and password doesn't matter then click on the new image that pops out.. press Done now you will be at stat setting window.. which you will see doesn't work.. but if you run statsetting window instead of login.php it will work perfectly whats wrong? I know it's not a <form> error.. because form is there in the index I have. PHP Code: <?php session_start(); ini_set('display_errors', '1'); //show errors. //include_once 'functions.php'; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script type="text/javascript" src="js/ajax.js"></script> <script type="text/javascript"> function updateUI(str) { var ajaxObj = new XMLHttp(); var url = 'ajax.php'; var method = 'POST'; var params = 'page='+str; makeRequest(ajaxObj, method, url, params, 'maincontent'); ajaxObj = null; } </script> </head> <body> <table border="1" align="center" width="440" height="330"> <tr> <th scope="col"> <form name="UI" id="UI" action="" onsubmit="return false;"> <div id="maincontent"> <?php include 'ajax/login.php'; ?> </div> </form> </th> </tr> </table> </body> </html> ajax.php is simply the data outputter. PHP Code: <?php $page = (isset($_POST['page']) ? $_POST['page'] : ''); if ($page == "login") { include 'ajax/login.php'; } elseif ($page == "dologin") { include 'ajax/dologin.php'; } elseif ($page == "startingstats") { include 'ajax/startingstats.php'; } elseif ($page == "rankings") { include 'ajax/rankings.php'; } elseif ($page == "updates") { include 'ajax/updates.php'; } elseif ($page == "howto") { include 'ajax/howto.php'; } else { include 'ajax/login.php'; } ?> now the ajax folder has all the scripts that get outputted.. lets say the login.php page in ajax folder for now PHP Code: <script type="text/javascript"> <!-- var ubool = 0; var pbool = 0; var jsuser = ''; var jspw = ''; function userCheck(user) { jsuser = user; ubool = (user.length > 0) ? 1 : 0; if(ubool && pbool) document.getElementById("login").style.visibility = "visible"; else document.getElementById("login").style.visibility = "hidden"; } function pwCheck(pass) { jspw = pass; pbool = (pass.length > 0) ? 1 : 0; if(ubool && pbool) document.getElementById("login").style.visibility = "visible"; else document.getElementById("login").style.visibility = "hidden"; } function doLogin() { var ajaxObj = new XMLHttp(); var url = 'ajax.php'; var method = 'POST'; var params = 'page=dologin&user='+jsuser+'&pw='+jspw; makeRequest(ajaxObj, method, url, params, 'maincontent'); ajaxObj = null; } //--> </script> <div style="position: fixed; top: 222px; margin-left: 120px; color: white;">Welcome Kongregate Name</div> <div style="position: fixed; top: 252px; margin-left: 2px; color: white;">Hero Name:</div> <div style="position: fixed; top: 282px; margin-left: 2px; color: white;">Password:</div> <div style="position: fixed; top: 252px; margin-left: 90px;"><input type="text" name="user" id="user" size="12" maxlength="20" value="" onInput="javascript:userCheck(this.value)" onpropertychange="javascript:userCheck(this.value)" /></div> <div style="position: fixed; top: 282px; margin-left: 90px;"><input type="text" name="pw" id="pw" size="12" maxlength="20" value="" onInput="javascript:pwCheck(this.value)" onpropertychange="javascript:pwCheck(this.value)" /></div> <div id="login" style="position: fixed; top: 252px; margin-left: 210px; visibility: hidden;"><input type="image" src="images/quest.jpg" width="96" height="64" onClick="javascript:doLogin()" /></div> <div style="position: fixed; top: 252px; margin-left: 334px;"><input type="submit" name="rankings" value="Ranking List" onClick="javascript:updateUI('rankings')"></div> <div style="position: fixed; top: 282px; margin-left: 357px;""><input type="submit" name="updates" value="Updates" onClick="javascript:updateUI('updates')"></div> <div style="position: fixed; top: 312px; margin-left: 300px;"><input type="submit" name="howto" value="How to get started" onClick="javascript:updateUI('howto')"></div> <img src="images/splash.jpg" width="440" height="330" /> yes it has no forms in the page above so javascript shouldn't function right? Wrong look at index.php it has a <form> wrapper that wraps the <div> which gets updated by the ajax.php outputter that outputs ajax folder pages. Note okay that works.. the javascript functions on it all wonderfully. Now in this ajax/login.php thats loaded if you login with lets say pkedpker it checks it using index.php's javascript ajax call to ajax.php which calls dologin.php page in ajax folder. ajax/dologin.php is simply PHP Code: <?php //if(isset($_POST['user']) &&isset($_POST['pw'])) { // echo "user and password both set"; if($_POST['user'] == "pkedpker") { //and IS ALSO NEWBIE! STATING SCREEN COMES NEXT ?> <div style="background-color: #000000; color: #FFFFFF; font-weight: bold; width: 440px; height: 330px;"> A young hero arises from the plebium masses! <div style="position: fixed; top: 312px; margin-left: 300px;"><input type="submit" name="login" value="Done" onclick="javascript:updateUI('startingstats')"></div> </div> <?php } elseif($_POST['user'] != "pkedpker") { ?> <div style="background-color: #000000; color: #FFFFFF; font-weight: bold; width: 440px; height: 330px;"> Error: Hero Not Found [ <?php echo $_POST['user'] ?> ] <div style="position: fixed; top: 312px; margin-left: 300px;"><input type="submit" name="login" value="Done" onclick="javascript:updateUI('login')"></div> </div> <?php } else { ?> <div style="background-color: #000000; color: #FFFFFF; font-weight: bold; width: 440px; height: 330px;"> Error/Hack Attempt?: Username or password were found to be empty! <div style="position: fixed; top: 312px; margin-left: 300px;"><input type="submit" name="login" value="Done" onclick="javascript:updateUI('login')"></div> </div> <?php } ?> Nothing important just a few little tests I've setup.. the test that is interesting me is the 'A young hero arises' which has a ajax call to index.php that calls ajax.php which then includes a page from ajax folder called startingstats This is the ajax/startingstats.php code PHP Code: <script type="text/javascript"> <!-- var buildPts = 20; function buildPointsCheck(skill, direction, isMoney) { if(isMoney === 0) { if(direction == 1 && buildPts > 0) { buildPts--; skill.value++; } else if(direction === 0 && skill.value > 0) { buildPts++; skill.value--; } } else { var curMoney = (skill.value >= 25) ? skill.value / 25 : 0; if(direction == 1 && buildPts > 0) { buildPts--; curMoney++; } else if(direction === 0 && curMoney > 0) { buildPts++; curMoney--; } skill.value = (curMoney * 25); } if(buildPts === 0) { document.getElementById("login").style.visibility = "visible"; } else { document.getElementById("login").style.visibility = "hidden"; } document.getElementById("buildpoints").value = buildPts; } function buildOptionsCheck(buildOption) { if(buildOption.checked) { if(buildOption.name == "wizard" && buildPts >= 9) { buildPts-=9; } else if(buildOption.name == "trader" && buildPts >= 10) { buildPts-=10; } else if(buildOption.name == "warrior" && buildPts >= 8) { buildPts-=8; } else if(buildOption.name == "sage" && buildPts >= 12) { buildPts-=12; } else { buildOption.checked = false; } } else { if(buildOption.name == "wizard") { buildPts+=9; } else if(buildOption.name == "trader") { buildPts+=10; } else if(buildOption.name == "warrior") { buildPts+=8; } else if(buildOption.name == "sage") { buildPts+=12; } } if(buildPts === 0) { document.getElementById("login").style.visibility = "visible"; } else { document.getElementById("login").style.visibility = "hidden"; } document.getElementById("buildpoints").value = buildPts; } function setStats() { var ajaxObj = new XMLHttp(); var url = 'ajax.php'; var method = 'POST'; var params = 'page=startingstats&guts='+document.getElementByName("guts").value+'&wits='+document.getElementByName("wits").value+'&charm='+document.getElementByName("charm").value+'&money='+document.getElementByName("money").value+'&wizard='+document.getElementByName("wizard").value+'&trader='+document.getElementByName("trader").value+'&warrior='+document.getElementByName("warrior").value+'&sage='+document.getElementByName("sage").value; makeRequest(ajaxObj, method, url, params, 'maincontent'); ajaxObj = null; } //--> </script> <div style="background-color: #0000FF; color: #FFFFFF; font-weight: bold; width: 440px; height: 330px;"> <table border="1" align="center"> <th colspan="3"><span style="color: #00FF00; font-weight: bold;">stepansky</span></th> <tr> <td> <div align="center"><span style="color: #FFFF00; font-weight: bold;">Guts</span><br /> <table> <tr> <td><input name="button" type="button" value="+" onClick="javascript:buildPointsCheck(this.form.guts, 1, 0)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td> <td rowspan=2><input type="text" name="guts" value="4" size="5"></td> </tr> <tr> <td><input name="button2" type="button" value="-" onClick="javascript:buildPointsCheck(this.form.guts, 0, 0)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td> </tr> </table> </div> </td> <td> <div align="center"><span style="color: #FFFF00; font-weight: bold;">Wits</span><br /> <table> <tr> <td><input name="button" type="button" value="+" onClick="javascript:buildPointsCheck(this.form.wits, 1, 0)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td> <td rowspan=2><input type="text" name="wits" value="4" size="5"></td> </tr> <tr> <td><input name="button2" type="button" value="-" onClick="javascript:buildPointsCheck(this.form.wits, 0, 0)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td> </tr> </table> </div> </td> <td> <div align="center"><span style="color: #FFFF00; font-weight: bold;">Charm</span><br /> <table> <tr> <td><input name="button" type="button" value="+" onClick="javascript:buildPointsCheck(this.form.charm, 1, 0)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td> <td rowspan=2><input type="text" name="charm" value="4" size="5"></td> </tr> <tr> <td><input name="button2" type="button" value="-" onClick="javascript:buildPointsCheck(this.form.charm, 0, 0)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td> </tr> </table> </div> </td> </tr> <tr> <td colspan="2"> <div align="center"><span style="color: #FFFF00; font-weight: bold;">Options</span> <table width="100%" border="0"> <tr> <td><input type="checkbox" name="wizard" value="" onClick="javascript:buildOptionsCheck(this.form.wizard)"> Wizard 9p</td> <td><input type="checkbox" name="trader" value="" onClick="javascript:buildOptionsCheck(this.form.trader)"> Trader 10p</td> </tr> <tr> <td><input type="checkbox" name="warrior" value="" onClick="javascript:buildOptionsCheck(this.form.warrior)"> Warrior 8p</td> <td><input type="checkbox" name="sage" value="" onClick="javascript:buildOptionsCheck(this.form.sage)"> Sage 12p</td> </tr> </table> </div> </td> <td> <div align="center"><span style="color: #FFFF00; font-weight: bold;">Money(1p=$25)</span><br /> <table> <tr> <td><input name="button" type="button" value="+" onClick="javascript:buildPointsCheck(this.form.money, 1, 1)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td> <td rowspan=2><input type="text" name="money" value="25" size="7"></td> </tr> <tr> <td><input name="button2" type="button" value="-" onClick="javascript:buildPointsCheck(this.form.money, 0, 1)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td> </tr> </table> </div> </td> </tr> <tr> <td> <div align="center"><span style="color: #FFFF00; font-weight: bold;">Build Points left</span><br /> <input type="text" id="buildpoints" name="buildpoints" value="20" size="5"> </div> </td> <td> <div id="login" style="visibility: hidden;"> <input type="image" src="images/quest.jpg" width="96" height="64" onClick="javascript:setStats()" /> </div> </td> <td> <center> <input type="image" onClick="javascript:updateUI('login')" src="images/exit.jpg" /> </cener> </td> </tr> </table> </div> Now just including ajax/startingstats.php in index.php instead ajax/login.php IT FUNCTIONS perfectly!. Now if I let it all run normal using dologin.php to make the startingstats.php page load up which it does.. the javascript doesn't function tell me why? can someone please tell me why I've attached the whole project if someone wants to test it No MYSQL required.. just PHP Thank you! Similar TutorialsHi all, just before i kick off im not looking for the code just a push in the right direction. I am using a wysiwyg editor (tiny mce) which is basicaly a textarea with content in it. What i am looking to do is when a presses enter withing the textarea a <br/> tag is placed where the text curser is. Code: <textarea> <p>dfsdfdfdfdfdf dsfsdfdf dsfdsfdsf dsfdsfds dsfdfdss [enterpressed]<br/> dffdsf dfs dsfd sdf sdfs fdsf</p> </textarea> secondly, if a user users the arrow keys to navigate where to edit, when they get to the begining or the end of a tag, i want the arrows to be disabled. Code: <textarea> <p>||<df<sdf<dfd<fdfdf dsfsdfdf dsfdsfdsf dsfdsfds dsfdfdss [enterpressed]<br/> dffdsf> dfs> dsfd s>df sdfs>> fds>f||</p> </textarea> (<> represents arrow press, || represents blocked, and can go no further) any help much appreciated. Hey all, Objective: - when you select other the pull down menu is replaced by the text field. Currently: - Gotten it to the level of when you select the other the text field appears. Question: - HOw can I modify the code so when I select the other menu option from the pull down menu and it replaced by the text field? Quote: <script type="text/javascript"> function togglefield(val) { var o = document.getElementById('other'); (val == 'Other')? o.style.display = 'block' : o.style.display = 'none'; } </script> and the form: <form action="" method="post"> <select name="sel" id="sel" onChange="togglefield(this.value);"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="Other">Other</option> </select> <input type="text" name="other" id="other" style="display: none;"> </form> Here is my example code Code: <html> <head> </head> <body onload="addtext()"> How do I keep the cursor position after the " has been replaced with &quot;?<br><br> <form name="update" id="update" method="post" action=""> <textarea name="description" id="description" value="" cols="55" rows="15" onKeyUp="addtext()">Type a quote here[] and see the cursor move to the end he </textarea> <br> Result:<br> <div name="outputtext" id="outputtext"></div> </form> </body> <script language="javascript" type="text/javascript"> function addtext() { var newtext = document.update.description.value; document.getElementById('outputtext').innerHTML = newtext.replace(/\r\n|\n/g,"<br />"); document.getElementById('description').value = newtext.replace(/"/g,"""); } </script> </html> 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, 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 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? 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 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 to all, I'm a php person and I have a problem: I need to attach another value when an option is selected, the code below is only part of it but maybe you can see what I want to do. When an option is selected $username I need allso $id, can I do a appendChild or something, maybe my question is a bit stupid. Code: var newTextbox = document.createElement('select'); newTextbox.className = 'fn-select'; newTextbox.name = "opcion"; var op1 = new Option("", "<?php echo"$username" ?>"); newTextbox.appendChild(op1); var txt1 = document.createTextNode('<?php echo"$username" ?>'); op1.appendChild(txt1); editAreaText.appendChild(newTextbox); editArea.appendChild(editAreaText); Here is the full script including the php: PHP Code: <!-- Populate list with friends START--> var newTextbox = document.createElement('select'); newTextbox.className = 'fn-select'; newTextbox.name = "opcion"; //First user in the populated select menu is the person Loged in var op1 = new Option("", "<?php echo"$username"; ?>"); newTextbox.appendChild(op1); var txt1 = document.createTextNode('Me | <?php echo"$username"; ?>'); op1.appendChild(txt1); //Next users are my friends in the database <?php mysql_select_db("dnlife", $con); $result = mysql_query("SELECT * FROM `dnl_friends` WHERE `user_id` = '$id' OR `friends_id` = '$id'"); if(mysql_num_rows($result)) { while($row = mysql_fetch_array($result)) { $current = ($row['user_id'] == $id)?$row['friends_id']:$row['user_id']; //With each id now we get the name from database $lista_amigos = mysql_query("SELECT * FROM `dnl_users` WHERE `id` = '$current'"); $i = "1"; $op = $i++; while($row_users = mysql_fetch_array($lista_amigos)) { echo " var op".$op." = new Option(\"\", \"$row_users[nombre]\"); newTextbox.appendChild(op".$op."); var txt".$op." = document.createTextNode('$row_users[nombre]'); op".$op.".appendChild(txt".$op."); "; }}} else { echo ""; } ?> editAreaText.appendChild(newTextbox); editArea.appendChild(editAreaText); <!-- Populate list with friends END--> I have this js function on modalpopupextender which has a button. when you click the button, it shows a progress bar on parent page, till it gets all the data, but not i want to hide that progress bar div when parent page reloads after getting data. I am not sure how to do that, and I need to do that on modal page, since there could be any number of parent pages with that modal. I have my sample code here, let me know the window.parent function doesnot work. <style type="text/css"> .loading {display:none; position:absolute; padding:5px; border:solid 1px #888888; background-color:#fff; width:93px; z-index:20001; filter:alpha(opacity=80); opacity:0.8;} </style> <asp:ImageButton ImageUrl="~/Images/ExcelIcon.gif" runat="server" ID="Excel" CausesValidation="false" style="cursor:hand;" /> <br /> <asp:Label ID="lblExportExcel" runat="server" SkinID="ToolBarIconLabel">Excel</asp:Label> <script type="text/javascript"> function ShowProgress() { document.getElementById("ind").style.display = "inline"; } window.parent.onload = function() { document.getElementById("ind").style.display = "none"; } </script> <!-- Pop Up Form --> <div style="position: fixed; top: 0px; left: 0px;"> <asp:Panel ID="ExportExcelPanel" runat="server" SkinID="ModalPopUp_Panal" style="display:none"> <table class="ModalPopUp_Table" cellpadding="0" cellspacing="0" > <tr> <th colspan="2"> <asp:Panel ID="ExportExcelDragPanel" runat="server">Export Excel</asp:Panel> </th> </tr> <tr><td style="text-align: right;">Description:</td><td><asp:TextBox ID="descriptionBox" runat="server" TextMode="MultiLine" Height="60" Width="300"></asp:TextBox></td></tr> </table> <asp:ValidationSummary ID="ValidationSummary_ExportPDF" SkinID="ModalPopUp_ValidationSummary" runat="server" ValidationGroup="ExportPDF"/> <div class="BtnSumbit_Container"> <asp:Button ID="ExportExcelButton" runat="server" Text="Export Excel" OnClick="Excel_Click" CssClass="BtnSubmit" OnClientClick="ShowProgress();" UseSubmitBehavior="false" /> <asp:Button ID="CancelViewButton" runat="server" Text="Cancel" CssClass="BtnSubmit" /> </div> </asp:Panel> </div> <div class="loading" id="ind">Processing...</div> <actk:ModalPopupExtender ID="ExportExcelModalExtender" runat="server" SkinID="MPE_ReportFunction" PopupControlID="ExportExcelPanel" PopupDragHandleControlID="ExportExcelDragPanel" TargetControlID="Excel" CancelControlID="CancelViewButton" OkControlID="ExportExcelButton" Y="150" > </actk:ModalPopupExtender> I run a small nonprofit org, and am looking to upgrade our site to something cleaner like UNBOUNDARY'S website he http://www.unboundary.com/ Don't laugh, but I build our website with Microsoft Publisher, so I don't know any Code or Javascript. Is there any way I can have this "middle scrolling frame" like they do without having to know code. Perhaps an easy cut & paste code I can embed to give me that middle frame. Any assistance you can give is appreciated. Thanks, DOC I designed a simple mobile in html , i want to link it to strings such that.... example : there are numbers from 0 to 9 and when ever i click on a number and then click on another after all the click i made and at last when i click on the " dial" (for example purpose) it should prompt all the numbers in sequence where i click. example to make it clear for my purpose : 1 2 3 4 5 6 7 8 9 * 0 # Dial (button) I clicked on "4" then "6" then "9" and then i hit the "dial" button the it shold show an alert box displaying "469" . I think it isn't a big challenge for you javascript coders. Please post the whole javascript code for this function, also the id's defined to the html separetly by you I am just learning and up on queries , so want your help Thaks a ton I am working on an assignment. I will be upfront about that. I am not looking for someone to write my code for me. I do have the algorithm laid out and I'm almost positive this algorithm will work. I am a computer science student who has programmed in everything from assembly type languages to C/C++, .NET, JAVA and others. I am well educated in the concepts of programming and good programming practices. Having said all that one thing that annoys me the most is when I know what I want my code to do but I have a hard time finding out how to get the required language to do that. Take all that and then throw it on to the big ole mess of now I need to write up an HTML form (easy) and have JavaScript "process" the form and using that make a table (graph really) to be inserted into the .innerHTML of the body in said web page. So I have my form coded and my logic worked out. There are two buttons at the bottom of this form entitled "submit" and "reset". Naturally the reset button puts the form fields back to their default values. However that is the only part of my assignment that works. My idea was to write a JavaScript function that would execute when the user clicked the "make table" button. The JavaScript function would assign all the form field values to variables and then it would proceed to make a table and fill it in based upon those values. The beginning and end of the table code would just be "inserted" into the table string but the middle parts would be generated by a loop and the variables I got from the form field values. After all this good stuff is done, JavaScript should insert this "HTML String" into the .innerHTML section of a <body> tag. Sounds like it should be simple, but I can't even get JavaScript to read the form field values into variables like it "should". I can use the document.FORMNAME.FORMFIELD.value method but I'm supposed to use the document.getElementByID() method to do it. So I want to pass the entire form to my "Make Table" function and then from there use the statement variable1 = document.getElementByID(fieldname).value for each fieldname and then I would have all my field "values". From there I would need to generate a table "string" which is html code to be inserted into the .innerHTML of the <body>.... getElementByID() is doing nothing for me right now. So I'm stuck there for the moment. Here is my code: [CODE] <html> <head> <script type="text/JavaScript"> var lbl1 = "fish" ; function MakeTable() { lbl1 = document.getElementByID('label1').value; alert(lbl1.value); } function printvar() { document.writeln(lbl1); } </script> </head> <body> <form name="myform"> <h1> Author:</h1> <!-- Start of first form line --> <input type="text" id="addcolor" /> <input type="button" value ="Add Color"> <br/> <!-- End of first form line --> <!-- Start of second form line --> Label 1: <input type="text" id='label1' value="USA"> <select id="colors"> <option value ="Black"> Choose One</option> <option value="Red">Red</option> <option value="Blue">Blue</option> <option value="Yellow">Yellow</option> <option value="Green">Green</option> <option value="Purple">Purple</option> </select> Value: <input type="radio" id="num" value ="1" /> 1 <input type="radio" id="num" value ="2" /> 2 <input type="radio" id="num" value ="3" /> 3 <input type="radio" id="num" value ="4" /> 4 <input type="radio" id="num" value ="5" /> 5 <br/> <!-- End of second form line --> <!-- Start of third form line --> Label 2: <input type="text" id="label2" value="England"> <select id="colors"> <option value ="Black"> Choose One</option> <option value="Red">Red</option> <option value="Blue">Blue</option> <option value="Yellow">Yellow</option> <option value="Green">Green</option> <option value="Purple">Purple</option> </select> Value: <input type="radio" id="num" value ="1" /> 1 <input type="radio" id="num" value ="2" /> 2 <input type="radio" id="num" value ="3" /> 3 <input type="radio" id="num" value ="4" /> 4 <input type="radio" id="num" value ="5" /> 5 <br/> <!-- End of third form line --> <!-- Start of forth form line --> Label 3: <input type="text" id="label3" value="South Korea"> <select id="colors"> <option value ="Black"> Choose One</option> <option value="Red">Red</option> <option value="Blue">Blue</option> <option value="Yellow">Yellow</option> <option value="Green">Green</option> <option value="Purple">Purple</option> </select> Value: <input type="radio" id="num" value ="1" /> 1 <input type="radio" id="num" value ="2" /> 2 <input type="radio" id="num" value ="3" /> 3 <input type="radio" id="num" value ="4" /> 4 <input type="radio" id="num" value ="5" /> 5 <br/> <!-- End of forth form line --> <!-- Start of fifth form line --> Label 4: <input type="text" id="label4" value="Poland"> <select id="colors"> <option value ="Black"> Choose One</option> <option value="Red">Red</option> <option value="Blue">Blue</option> <option value="Yellow">Yellow</option> <option value="Green">Green</option> <option value="Purple">Purple</option> </select> Value: <input type="radio" id="num" value ="1" /> 1 <input type="radio" id="num" value ="2" /> 2 <input type="radio" id="num" value ="3" /> 3 <input type="radio" id="num" value ="4" /> 4 <input type="radio" id="num" value ="5" /> 5 <br/> <!-- End of fifth form line --> <!-- Start of fifth form line --> Label 5: <input type="text" id="label5" value="Congo"> <select id="colors"> <option value ="Black"> Choose One</option> <option value="Red">Red</option> <option value="Blue">Blue</option> <option value="Yellow">Yellow</option> <option value="Green">Green</option> <option value="Purple">Purple</option> </select> Value: <input type="radio" id="num" value ="1" /> 1 <input type="radio" id="num" value ="2" /> 2 <input type="radio" id="num" value ="3" /> 3 <input type="radio" id="num" value ="4" /> 4 <input type="radio" id="num" value ="5" /> 5 <br/> <!-- End of fifth form line --> <!-- Make Table and Reset Buttons--> <input type="button" value ="Make Table" onclick="MakeTable(myform)" > <input type="Reset" value ="Reset" > </form> </body> </html> [CODE] any help would be appriciated |