JavaScript - Js Does Not Execute The Expression For No Reason!
I have the following function:
Code: function sonKare(sayac, oteki) { var vertical, horizontal = hangiYataySira(sayac, oteki), j, k, l, m, united, tekRakam, actualV = [], actualH = [], numaralar = [1, 2, 3, 4, 5, 6, 7, 8, 9], olmayanlar = []; if(ilkSefer === true) { vertical = hangiDikeySira(rakamlar.length); ilkSefer = false; } else { vertical = hangiDikeySira(rakamlar.length - 1); } for(j = 0; j <= vertical.length - 1; j ++ ) { if(rakamlar[vertical[j]] !== undefined) actualV.push(rakamlar[vertical[j]]); } for(k = 0; k <= horizontal.length - 1; k ++ ) { if(rakamlar[horizontal[k]] !== undefined) actualH.push(rakamlar[horizontal[k]]); } united = actualV.concat(actualH); //---- Olmayan rakamları bulan kısım ------------ outer: for(l = 0; l <= numaralar.length - 1; l++) { for(m = 0; m <= united.length - 1; m++) { if(numaralar[l] === united[m]) continue outer; if(m === united.length - 1 && numaralar[l] !== united[m]) olmayanlar.push(numaralar[l]); } } //---------------------------------------------- if(olmayanlar.length > 1 || olmayanlar.length === 0) { rakamlar = []; document.form1.buton.click(); // THIS LINE DOES NOT WORK SECOND TIME } else { $("_" + oteki + "_" + sayac).value = olmayanlar[0]; rakamlar.push(olmayanlar[0]); sayac++; if(sayac === 10) return; else sonKare(sayac, oteki); //CALLS ITSELF } } This is a recursive function. As stated above there is a line which does not work for the second time. What I mean is, it works perfect for the first time and after function calls itself, it doesn't work. Javascript does execute the line above it but just disregards that document.form1.buton.click(); line. I use Firebug for debugging and I checked it many times, when that expression needs to be executed for the second time, JavaScript just ignores it and immediately goes at the end of the function... I just can't figure out why JS does such a thing? p.s: Don't bother about weird variable names, they are not in English but in Turkish which is my native language Similar TutorialsThis code snippet below was extracted from a rather large javascript. It is not written here to function alone, but it is solely to illustrate my question, Why can't a variable be read from within a function when it has been set as the text of a url address, in this case www.google.com)? When I click on the browser HREF that calls the OnClick event, the function SwitchFN, I receive the following 2 alerts: "Ones" (variable is output as expected) "undefined" (the second variable is no longer defined within the function, however using the command alert(numtwo) in the variable definition section of my code will work as expected and the alert will be "www.google.com" Why can't the function see the variable when it is a URL? Code: I have set several default variables up in the beginning of my script: var numone = "Ones" var numtwo = "www.google.com" /// more variables set /// more functions function switchfn(nfn,nrm) { document.cookie = "mvrfile=" + numone alert(numone) alert(numtwo) } document.write('<TR><TD BGCOLOR=# ALIGN=LEFT VALIGN=top WIDTH=60 COLSPAN=2><A HREF="#" onClick="switchfn(\'' + myview + '\',\'' + mytxt + '\')">' + mytxt + '</A></TD></TR>') ; I am attempting to create a web based quote system that pops up a preview of the fencing type selected on click. but nothing works.. im frustrated with this and need a bit of guidance. hopefully someone will help here is the HTML body of the form Code: <body> <form action="" id="fenceprice" onsubmit="return false;"> <fieldset> <legend>Let's get a quote together for you!</legend> <p>How many feet of fencing do you need? <input type="number" name="length" min="1"></p> <label >Type of fence (Price/foot)</label><br> <input type="radio" name="fence" value="StockadePrivacy" onclick="calculateTotal()" /> Stockade Privacy Fence ($13.99)<br> <input type="radio" name="fence" value="OverlappingPrivacy" onclick="calculateTotal()" /> Overlapping Privacy Fence ($14.99)<br> <input type="radio" name="fence" value="ShaddowboxPrivacy" onclick="calculateTotal()" /> Shaddowbox Privacy Fence ($15.99)<br> <input type="radio" name="fence" value="3BoardHorse" onclick="calculateTotal()" /> 3 Board Horse Fence ($5.99)<br> <input type="radio" name="fence" value="4BoardHorse" onclick="calculateTotal()" /> 4 Board Horse Fence ($6.99)<br> <input type="radio" name="fence" value="4FtChain" onclick="calculateTotal()" /> 4 foot Chain Link Fence ($6.50)<br> <input type="radio" name="fence" value="6FtChain" onclick="calculateTotal()" /> 6 foot Chain Link Fence ($7.99)<br> <input type="radio" name="fence" value="4FtField" onclick="calculateTotal()" /> 4 foot Field Fence ($5.25)<br> <input type="radio" name="fence" value="6FtField" onclick="calculateTotal()" /> 6 foot Field Fence ($7.25)<br> <input type="radio" name="fence" value="4FtNoClimb" onclick="calculateTotal()" /> 4 foot Field Fence with No Climb Wire ($5.73)<br> <input type="radio" name="fence" value="4FtCross" onclick="calculateTotal()" /> 4 foot Cross Fence ($6.75)<br> <input type="radio" name="fence" value="4FtCrossWire" onclick="calculateTotal()" /> 4 foot Cross Fence with No Climb Wire ($7.25)<br> <input type="radio" name="fence" value="BarbedWire" onclick="calculateTotal()" /> 4 Strand Barbed Wire Fence ($5.00)<br> <input type="radio" name="fence" value="4FtVinyl" onclick="calculateTotal()" /> 4 foot Vinyl Fence ($15.99)<br> <input type="radio" name="fence" value="6FtVinyl" onclick="calculateTotal()" /> 6 foot Vinyl Fence ($17.99)<br> <p> <label for='includepaint' class="inlinelabel"> Include Paint($1.25/foot)</label> <input type="checkbox" id="includepaint" name='includepaint' onclick="calculateTotal()" /> </p> <p> <input type= "submit" name="submit" onclick="calculateTotal()" /> </p> <div id="totalPrice"></div> </fieldset> </form> </body> here is my js for the preview images (js.js) Code: var app = preview.module('app' , ['ui.filters']); function MainController($scope) { function Preview(type, imageSrc){ this.type = type; this.imageSrc = imageSrc; }; var fenceType = [ new Fence("StockadePrivacy" , "nicks work/single gate stockade.jpg"), new Fence("OverlappingPrivacy" , "nicks work/board over board privacy fence (3).jpg"), new Fence("ShaddowboxPrivacy" , "nicks work/shadowbox (2).jpg"), new Fence("3BoardHorse" , ""), new Fence("4BoardHorse" , "nicks work/titan (37).jpg"), new Fence("4FtChain" , ""), new Fence("6FtChain" , "nicks work/1003154_498266626917855_1385007596_n.jpg"), new Fence("4FtField" , "nicks work/wire by road.jpg"), new Fence("6FtField" , "nicks work/field wire.jpg"), new Fence("4FtNoClimb" , ""), new Fence("4FtCross" , "nicks work/cross fence black.jpg"), new Fence("4FtCrossWire" , ""), new Fence("BarbedWire" , ""), new Fence("4FtVinyl" , "nicks work/4ft vinyl.jpg"), new Fence("6FtVinyl" , "nicks work/6ft vinyl.jpg") ]; $scope.fenceType = fenceType; $scope.getCurrentFenceImage = getCurrentFenceImage; function getCurrentFence() { return_.find($scope.fenceType, { type: $scope.fenceType}) || {}; } function getCurrentFenceImage() { return getCurrentFence().imageSrc; }; } here is my code for the form calculations (formcalculations) Code: var fence_price = new Array(); fence_prices["StockadePrivacy"]=13.99; fence_prices["OverlappingPrivacy"]=14.99; fence_prices["ShaddowboxPrivacy"]=15.99; fence_prices["3BoardHorse"]=5.99; fence_prices["4BoardHorse"]=6.99; fence_prices["4FtChain"]=6.5; fence_prices["6FtChain"]=7.99; fence_prices["4FtField"]=5.25; fence_prices["6FtField"]=7.25; fence_prices["4FtNoClimb"]=5.73; fence_prices["4FtCross"]=6.75; fence_prices["4FtCrossWire"]=7.25; fence_prices["BarbedWire"]=5; fence_prices["4FtVinyl"]=15.99; fence_prices["6FtVinyl"]=17.99; function getQuantity() { //Assume form with id="theform" var theForm = document.forms["fenceprice"]; //Get a reference to the TextBox var length = theForm.elements["length"]; var howmuch =0; //If the textbox is not blank if(quantity.value!="") { howmuch = parseInt(quantity.value); } return howmuch; } function paintPrice() { var paintPrice=0; //Get a reference to the form id="fenceform" var theForm = document.forms["fenceprice"]; //Get a reference to the checkbox id="includecandles" var includePaint = theForm.elements["includepaint"]; //If they checked the box set candlePrice to 5 if(includePaint.checked==true) { paintPrice=1.25; } //finally we return the candlePrice return paintPrice; } function getFenceSizePrice() { var fenceSizePrice=0; //Get a reference to the form id="fenceform" var theForm = document.forms["fenceform"]; //Get a reference to the fence the user Chooses name=selectedCake": var selectedFence = theForm.elements["selectedfence"]; //Here since there are 4 radio buttons selectedCake.length = 4 //We loop through each radio buttons for(var i = 0; i < selectedFence.length; i++) { //if the radio button is checked if(selectedFence[i].checked) { fenceSizePrice = fence_prices[selectedFence[i].value]; break; } } //We return the fenceSizePrice return fenceSizePrice; } function getTotal() { //Here we get the total price by calling our function //Each function returns a number so by calling them we add the values they return together var fencePrice = getFenceSizePrice() * getQuantity() + paintPrice() * getQuantity(); //display the result var divobj = document.getElementById('totalPrice'); divobj.style.display='block'; divobj.innerHTML = "Total Price For Fencing $"+fencePrice; } function hideTotal() { var divobj = document.getElementById('totalPrice'); divobj.style.display='none'; } Reply With Quote 12-19-2014, 01:01 AM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,311 Thanks 82 Thanked 4,754 Times in 4,716 Posts So have you used your error console? Or your JavaScript debugger? Hit the F12 key to bring up both. I recommend using the Chrome browser for this because I like its integration of the console and debugger, et. al., best. But any modern browser will do. Are you getting errors right off the bat from the error console? Are you getting errors when you try to select a fence, etc.? Tell us *WHAT* is going wrong. Don't make us re-construct your page so we can use our error console. And if you still can't figure it out, can you post the page LIVE someplace? Give us a URL to look at? Hi there, i have this simple script that replaces the scrollbar of an iframe called iFrame1 with 2 up and down arrow images, but it only works in IE, i've tried it in Chrome and Firefox... here is the code Code: <script type="text/javascript" language="javascript"> function bsh_iFrame1(step,time){hs_iFrame1=setInterval("sh_iFrame1("+step+")",time)} function esh_iFrame1(){clearInterval(hs_iFrame1)} function sh_iFrame1(step) { scrollx=iFrame1.document.body.scrollLeft scrolly=iFrame1.document.body.scrollTop scrolly=scrolly+step iFrame1.window.scroll(scrollx,scrolly) } </script> Code: </td><td align="center" valign="middle" width="31"><img src="up.png" alt="up" border=0 vspace="5" hspace="3" onMouseDown="esh_iFrame1();bsh_iFrame1(-3,2)" onMouseUp="esh_iFrame1();bsh_iFrame1(-1,20)" onMouseOver="bsh_iFrame1(-1,20)" onMouseOut="esh_iFrame1()"><br> <img src="down.png" alt="down" border=0 vspace="5" hspace="3" onMouseDown="esh_iFrame1();bsh_iFrame1(3,2)" onMouseUp="esh_iFrame1();bsh_iFrame1(1,20)" onMouseOver="bsh_iFrame1(1,20)" onMouseOut="esh_iFrame1()"> thanks in advance for any answers... I am trying to fix some datetime strings so I can convert form values into date objects so I can compare the dates in my validation process. the date time strings look like - 7/21/2011 8:00am for some reason the am is not being replaced by " am" . here's the function Code: function ampm(str){ str.replace(/am/gi," am") str.replace(/pm/gi," pm") return str } for example the result of ampm("8:00am") is 8:00am and not 8:00 am .. it seems so simple. Hi, I'm making a Google Map that reads info from a database and pulls Twitter usernames from it to plot points on a map. In the infowindow of these points I have some code that displays the Twitter users latest tweet. There's alot of code for this map so i'll only show you the part i'm working on: Code: function readData() { var request = GXmlHttp.create(); request.open("GET", "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 = '<' + 'script src="http://twitter.com/javascripts/blogger.js"><' + '/script><' + 'script type="text/javascript" src="http://twitter.com/statuses/user_timeline/' + label + '.json?callback=twitterCallback2&count=1"><' + '/script><br /><div id="twitter_update_list" style="list-style:none"></div>'; // 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); } var html is where it's all happening. I'm using the Twitter script from http://limetouch.com/article/valid-x...vascript-code/ and I have it laid out with all them ' + ' to break it up so it doesn't end the actual javascript used to create the map. I'm new to Javascript so I don't know too much. I know that this method is a really backwards way of doing it, but it works for Firefox. I'm able to retrieve the users latest tweet when I click on their map marker. What I want to know is why it doesn't work in any other browser? I've tried IE7+8, Google Chrome, Opera, and Safari and no tweet displays. Sub-question: While a tweet does display in Firefox, the infowindow doesn't resize with the dynamic content. Any way to fix that? hi all. im having problems with this ajax script i wrote: Code: function admin_adduser() { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request"); return; } user = document.getElementById('user_user').value; user = user.replace(/^\s+|\s+$/g, '');// trim whitespace //check if name is unique unique = 'false'; var params = "?user=" + escape(user); var url="_check_username.php"; url=url+params; ajaxedInner = ""; xmlHttp.open("GET",url,true); xmlHttp.setRequestHeader("If-Modified-Since", "Fri, 31 Dec 1999 23:59:59 GMT"); xmlHttp.onreadystatechange=stateChanged; xmlHttp.send(null); xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4) { if (xmlHttp.status == 200) { unique = xmlHttp.responseText.replace(/^\s+|\s+$/g, ''); //trims all whitespace! //alert(unique); } } } if(unique == 'true') { //alert("working: " + unique); password = document.getElementById('user_password').value; var params = "?user_user=" + escape(user) + "&user_password=" + escape(password); var url="_admin_add_user.php"; url=url+params; ajaxedInner = "users"; xmlHttp.open("GET",url,true); xmlHttp.setRequestHeader("If-Modified-Since", "Fri, 31 Dec 1999 23:59:59 GMT"); xmlHttp.onreadystatechange=stateChanged; xmlHttp.send(null); document.getElementById('user_password').value = ""; document.getElementById('user_user').value = ""; } else { alert('Please select a unique name for the new staff member\nadd a middle initial maybe?'); } } if i alert(unique) it tells me 'true' (string) but still doesnt go into the create part of the script, i just get the alert('Please select a unique name for the new staff member\nadd a middle initial maybe?'); any ideas? i know im probably missing something basic but its really annoying lol btw - the php for the _check_username.php is simple: PHP Code: <?php if(!isset($_SESSION)) {session_start();} if($_SESSION['authorised'] != true) { exit; } include 'config.php'; include 'opendb.php'; $user = $_REQUEST['user']; $query = "SELECT user FROM user WHERE user='$user'"; echo $query; $result = mysql_query($query) or die('false'); $row = mysql_fetch_array($result, MYSQL_ASSOC); if($row) { echo 'false'; } else { echo 'true'; } mysql_free_result($result); ?> I started on the following page (part of an asp.net solution), but the damned thing keeps reloading. Anyone able to spot the problem? Cheers! Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title> Untitled Page </title></head> <body> <form name="form1" method="post" action="jstest3.aspx" id="form1"> <div> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTEwMjYxNzg2NjFkZMc95XPGgLBVJLhpE9SpA+WIaf+s" /> </div> <div> <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAwKUmIGgCgLs0bLrBgKM54rGBm+z7+T68pYhg8H9O6b/Ex0HpZ0A" /> </div> <div> <input name="TextBox1" type="text" id="TextBox1" /> <input type="submit" name="Button1" value="Button" id="Button1" /> <script language="javascript" type="text/javascript"> if (parent != null) { tb = parent.document.getElementById("TextBox"); tbLocal = document.getElementById('TextBox1'); if (tb != null) tbLocal.value = tb.value; btn = document.getElementById('Button1'); if (btn != null) btn.click(); } </script> </div> </form> </body> </html> Hi all. Can someone please help me make this code accurate so it counts the correct number of characters? when u click on the box, it should display 0. when u type in the box, it should count up by 1. when u click on the box, and u delete a character or characters, it subtracts that many code: Code: <form method="POST"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td width="100%"> <textarea onkeyDown="count_it(this)" rows="12" name="charcount" cols="60" wrap="virtual"></textarea> </td> </tr> <tr> <td width="100%"><div align="right"><p> <input type="text" name="displaycount" size="20"></p> </div></td> </tr> </table> </form> <script language="JavaScript"> function count_it(what){ formcontent=what.form.charcount.value what.form.displaycount.value=formcontent.length } </script> edit:: got it to work setting inBooth to false in the function where I clear the menu, but then it's refreshing to div so often while you're standing in the booth (30 frames/sec, it's a game) that nothing happens when you click the buttons to buy/sell unless you click really really fast.... anyone know a good way to check whether something is true, then toggle an innerHTML div, then once the value becomes false, toggle the innerHTML div to empty....??simply?? But if I reverse the order the opposite works but then the other doesn't...... Code: if (condition==true ) { generateSale(); inBooth=true; smithShop(); } else {inBooth=false;clearSale();} //IS PLAYER IN VENDOR BOOTH? if (condition2==true ) { generateSale(); inBooth=true; vendorShop(); } else {inBooth=false;clearSale();} Only the "generateSale()" from the second one executes. If I switch the if blocks, the second one with "generateSale()" executes. If I change "clearSale();" to a "setTimeout=('clearSale()',1000)" then both execute "generateSale()" but the div it affects flickers repeatedly as it's cleared/remade. generateSale() changes the innerHTML of a div, clearSale() just overwrites the innerHTML with ' ' Code: var sales2; function clearSale() { sales2=document.getElementById('sales2'); sales2.innerHTML=''; } function generateSale(){ sales2=document.getElementById('sales2'); sales2.innerHTML= 'Buy/Sell: '+' Gold coins: '+playerInventory[lootArray[7]]+'<br>' +' Consumables:<br>' +'You have: '+playerItems[itemArray[4]] +' arrows<br>' +'<input type="button" value="Buy" onclick="buyIt(0);">'+'10 for 50gp<br>' +'<input type="button" value="Sell" onclick="sellIt(0);">'+'10 for 25gp<br>' } Any ideas? Basically when my character enters the range of an image of a building I have a menu pop up saying you're in a vendor booth. I want it to run generateSale() which changes a div on the screen to list a bunch of stuff you can buy/sell. When your character is no longer standing in range, I want it to clear that information, so you have to be standing within range in order to trade items. Currently I can make it generates the sale menu, but it doesn't clear it when you leave the range. I've tried all kinds of "toggle" variables to set whether you're in range or not, but only the second block fires, not the first and I cannot figure out why... Any ideas? The code all works fine it just won't clear for all the different buildings, only one.... hi From inside a javascript function i need to execute a vbscript sub routine. You might be thinking why i can't do it in javascript. well i probably can but i am better at VBscript and it would be a lot easier. Thanks I am trying to change the background color of TD's that only the exact text PTO and really do not grasp regex's string/element examples: Code: <td class="ms-cal-todayitem"> Ward, Daniel M. - PTO - home - im awesome. </td> <td class="ms-cal-todayitem">Ward, Daniel M. - UPTO - home - im awesome. </td> I tried this: Code: $("td.ms-cal-todayitem").filter(function() { return /PTO/.test( $(this).text() ); }).css("background-color","#C4DBFF") but it also changes the background of items like my second element example. - Yes it should be case sensitive, if possible. Here is the link in question. I have created a small page with the isolated problem on it. http://frontendaudio.com/v/vspfiles/...pt_tester.html the javascript file that is referenced basically only does one thing. It searches for "> >" and then alerts us whether or not it's on the page. --- It pulls the innerHTML of the entire document --- the searches it - and indexes the string. I echoed the string out to a text area so you could see the string "> >" is clearly there after the word microphones in the link tag... </a> > < etc.. Any thoughts on how I can detect this string somehow? Thanks. Here is the code inside the javascript file. Code: var myStringDiscuss = 'microphones</a> >'; myStringDiscuss = myStringDiscuss.replace(/~/g,""); // unmunge function discussDetection(){ var str = document.getElementsByTagName('html')[0].innerHTML; str = str.toLowerCase(); // to make case insensitive var category_string = str.indexOf(myStringDiscuss); if (category_string == -1) { alert("not on this page"); } else { alert("IS on the page"); } } window.onload= discussDetection; For example, how can I write "Hello!" on the page every Friday at 8:40?
I am wondering if its possible to execute a JavaScript script as soon as the page is loaded? Perhaps a generic execution? I tried this, but it didn't work: Code: <SCRIPT type="text/javascript"> if (document.forms["form"]["quantitym"].value > '.$row['sizem'].') { alert ("The quantity for product $row['id'] is no longer available."); } </SCRIPT> <FORM action="updatecart.html" method="post" name="form"> <DIV> <B>Medium:</B> <INPUT name="quantitym" value="'.$content['sizem'].'"> </DIV> </FORM> This is for my shopping cart system. The idea is, the customer might have 4 items in his cart, but whilst he was shopping, someone might of bought the same item, result in only 3 being available, but his cart still says 4. My solution to this is to make a script run through out his shopping when ever the cart items are listed and just prior payment execution, if the quantity he wants is no longer available, he will be alerted. $row['sizem'] is PHP drawing how many items there are from my stock database. If the value of the INPUT exceeds this availability, JavaScript shall alert. Does anyone know why it isn't alerting? Quote: Originally Posted by mlseim hmmm .... sort of stumped. For a test, I made a script that pulls a random "bumper-sticker" quote out of a file and sends it back as Javascript. Put this on a test page of yours and see what happens: <script type="text/javascript" src="http://www.catpin.com/bumper_sticker3.php"></script> Wherever that line is, when you view your web page, it should have a random quote. It's using the same code that I had above (in post #2). how would you put <script type="text/javascript" src="http://www.catpin.com/bumper_sticker3.php"></script> into a function for javascript to call this php file? Im alright with .php but not good at javascript at all. this is the javascript code placed in the head tags of my page function confirmation() { var answer = confirm("Delete news item?") if (answer){ window.location = "main.php?id=delete¬e="+noteID+"&status=delete"; } else{ alert("No action taken") } } this is the .php that links to the javascript function PHP Code: if($this->admin){ echo ' <a href="?id=edit¬e='.$this->noteID.'&status=load" class="grey">[Edit]</a>' .'<a href="" onclick="confirmation('.$row['noteID'].')" class="grey">[Delete]</a>'; } this is the .php code that executes if the url is status=delete PHP Code: // This displays if id = Delete A News & user=ADMIN if( $id == "delete" && $session->isAdmin() ) { echo '<div id="major_game_news_header">'; echo '<h1>DELETION OF NOTE</h1></div>'; $stat = $_GET['status']; if($stat == "preview" && $session->isAdmin() ) { $noteID = $_GET['note']; echo '<div id="createnews">Are you sure? <a href="?id=delete¬e={$noteID}&status=delete">' .'Yes</a>. <a href="main.php">No</a></div>'; } if($stat == "delete" && $session->isAdmin() ) { $note->deleteNote();} } this line in the third code snippet works perfect: " PHP Code: <a href="?id=delete¬e={$noteID}&status=delete">Yes</a> " I'm having great difficulty for the "window.location =...... " to navigate to the right url. It doesn't include the noteID which enables me to delete news items. Any help would be greatly apreciated (: Hello, How can i validate string with alphanumeric, space, dash and dot in regular expression ? Hi: I think this is where I need to ask this. I am doing a PHP/mod_rewrite and I need to tweak one of the RegEx's used in it but I don't know the syntax. I have this bit of code: Code: <a href="http://www.mywebsite.com/Promotional.Products-Promotional.Items/Promotional-Products/<?php echo $product_id ?>-<?php echo str_replace(" ", "-", $myTitle) ?>-<?php echo $full_state ?>-Promotional-Products.html" title="<?php echo $myTitle?> <?php echo "$full_state"; ?>"><?php echo $myTitle?></a> RewriteRule ^Promotional.Products-Promotional.Items/Promotional-Products/([0-9]+)-([a-zA-Z]+)-([a-zA-Z]+)-Promotional-Products.html$ Promotional.Products-Promotional.Items/Promotional-Products.php?product_id=$1&myTitle=$2&full_state=$3 I wanted to know how I can revise the middle RegEx: Code: ...-([a-zA-Z]+)-... to include replacing all spaces with hyphens. Can someone help me with this, please. Thanks! Hi all, I have this line (part of a larger function that converts a few common BBCodes into HTML) and I don't know how to do one thing. First, here's the line: Code: str.replace(/\[color=(.*?)\](.*?)\[\/color\]/gi,'<span style="color:$1;">$2</span>'); It works fine if I do this (I'll mis-spell "color" to prevent messing up the board): THIS works fine..... [colur=#ff0000]Red Text[/colur] But of course, if I do this: [colur="#ff0000"]Red Text[/colur] It doesn't work. What I need to do is take the $1 variable, AFTER it's captured, but BEFORE it's used, and strip out any quote marks I find. I may want to also strip out, then add the hash sign (#) also, then put it back so it works with or without the #. While I'm at it, I'll also probably detect color as a hex string vs. a keyword (so that both "#ff0000" and "red" work) and probably also support the rgb() method. But first I need to know how to access and modify $1 BEFORE it's used. I'm hoping that I don't need to use two lines (or two separate .replace() calls). Thanks! -- Roger I am trying to find the correct regular expression (or an alternate) for if a user enter any more than 1-3 digits in the age field of a form it produces an error message. I already have the error set up, just the correct coding to produce the 1-3 digit condition. Thanks, KWIKCUCUMBER. |