JavaScript - Javascript Replace Function Not Working In Ie
I have a js replace function to replace text next to two radio buttons on a pre set form.
Script is as follows. Code: document.body.innerHTML = document.body.innerHTML.replace( "Payment by <b>Moneybookers</b> e-wallet<br>", "" ); document.body.innerHTML = document.body.innerHTML.replace( "Maestro, Visa and other credit/debit cards by <b>Moneybookers</b>", "Pago con Diners Club, Mastercard o Visa" ); The script works fine in Chrome and Firefox, however, the script is not actioned in Explorer. I believe it has something to do with there being , / - within the text I am replacing? When I use the function to replace text with no , / - in the text - it works fine in explorer, however, for example when I try to replace text.. - "Maestro, Visa and other credit/debit cards by Moneybookers" this does not work in explorer.. I'm assuming because of the coma and forward slash. Honestly I've tried everything but just can not get this to work. I have no access to the HTML table where the form is posted this is why I am attempting this funtion. Any help would be greatly appreciated!! Similar TutorialsHi, I am facing a problem in passing replace() function as an argument in user defined java function, can any one help me how to resolve it? intention is to pass a file path to my user defined function, but before passing the path i want to replace the character '\' to '\\' I am posting my javascript function he <a href="#" onclick="OpenDocPreview('<%# Eval("PATH")%>'.replace(/\\/g,"\\\\"), '<%# Eval("Filename")%>')"><%# Eval("DocTitle") %></a> function OpenDocPreview(url, docname) { alert('message from search base : ' + url + ' ' + docname); } thank you, I'll probably be laughed at for this attempt of coding, but all I am trying to do is read an input field, remove the "$" and write the new value in a different input field. Code: function convert_action (form){ var input1=form.input_field1.value; var clean=input1.replace(/$/, ''); form.input_field2.value = clean; } Looks simple, and thought this would work, it kindof does, it just does not strip out the dollar sign... Help would be appreciated...greatly... Code: s = s.replace(/\[code\](.*?)\[\/code\]/gi,'<span class="code">$1</span>'); This works as expected, but what I'm trying to do is replace the content within the tags with a santized version of what was in it before. Example Code: function clean(str){ //clean up string stuff here return str; } s = s.replace(/\[code\](.*?)\[\/code\]/gi,'<span class="code">'+clean('$1')+'</span>'); But as with everything in life it's never that easy, it's simply passing "$1" to the clean function instead of what was actually within the code tags. Can anyone tell me how I'd go about doing this? hello, i have a form validator that works fine in chrome, safari, firefox...but not IE 8.. i'm pretty new at javascript... any help is appreciated Code: function detect() { if(navigator.cookieEnabled == false) { alert('You must enable cookies in your browser!'); return false; } if(document.add.color.value == "-Select Color-") { alert('Please select a color!'); return false; } if(IsNumeric(document.add.quantity.value) != true) { alert('This must be a number!'); return false; } if(document.add.quantity.value == 0) { alert('You must add at least one item!'); return false; } } and the html Code: <form name='add' onSubmit='return detect();' method='POST' action='process.php'> Hi, I wonder if someone can help! I am not a JavaScript programmer at all, so I cant really see what I am doing wrong with the following code... Just to explain I have 2 fields on a form that retrieve monetary data from a mysql database. The data is a monetary value e.g. 12.59. Which works fine as normal. I have been asked to hide this value depending on what the customers preferences are set to i.e Show Price = Yes or Show Price = No. Hopefully that makes sense. After lots of deliberation I realised that I couldnt hide the fields because the database called an error saying the price data was missing. So I thought change the field type to a 'password field' and the price data would still be accepted by the database. This thankfully worked and didnt break the php code. So I found some javascript code, chopped and pasted it and came up with the following script. This is called with an onclick event through a link. <script language="JavaScript"> function changetype(){ var myTextField = document.getElementById('hf_showmobprices'); if(myTextField.value == "Yes") document.getElementById('price1jd').type='password'; document.getElementById('price2jd').type='password'; else return false; } I thought the above would work but it doesn't. If I take out one of the lines "document.getElementById('price2jd').type='password';", then it does work. After more playing around I thought, create a function caller as shown below but again that doesnt work. The first function works but the second function doesnt seem to work. I shoved in an alert just to check that the second function was being called and it is. So what I gather is It seems to convert the first price field to a password type field but not the second field. Does anyone know why? is it some thing to do with the getElement and can only run once? I am using FireFox 3.6 if that will help <script type="text/javascript"> function checkprefs() { price1(); price2(); } </script> <script language="JavaScript"> function price1(){ var myTextField = document.getElementById('hf_showmobprices'); if(myTextField.value == "Yes") document.getElementById('price1jd').type='password'; else return true; } </script> <script language="JavaScript"> function price2(){ var mynewtestField2 = document.getElementById('hf_showmobprices'); if(mynewtestField2.value == "Yes") document.getElementById('price2jd').type='password'; else alert("alert2") } </script> Any guidance would be much appreciated john Hey everyone. I have built a simple page for where I work, nothing complex going on here at all. But for some reason it won't run the Javascript functions in Firefox. Sarfari and Chrome work fine. It's not calling any external files or anything, like I said super simple. So if anyone can go to the page, view the source, take a look and let me know what I am missing here I would be greatly appreciative. http://www.aaronhager.com/BM/ To see what it does, just open that link in Chrome or Safari. I am more of a Flash guy then Javascript, and hopefully the reason is simple for one of you geniuses out there. Thanks A. I have an function that shoud be activated when the pull down menu in triggerd, the if functions is corresponding to the same menu overig_eenh[] PHP Code: function overig_tot_abs(selectVeld, nr) { // Prijs totaal if (document.getElementsByName('overig_eenh[]')[nr].value == 'totaal') { document.getElementsByName('overig_totaal[]')[nr].value = (document.getElementsByName('overig_prijs[]')[nr].value).toFixed( 2 ) } // Prijs kg if (document.getElementsByName('overig_eenh[]')[nr].value == 'kg') { document.getElementsByName('overig_totaal[]')[nr].value = (document.getElementsByName('overig_prijs[]')[nr].value * (document.getElementsByName('materiaal_tot_gew[]')[nr].value + document.getElementsByName('plaat_tot_gew[]')[nr].value)).toFixed( 2 ) } // Prijs verf opp. if (document.getElementsByName('overig_eenh[]')[nr].value == 'verf_opp') { document.getElementsByName('overig_totaal[]')[nr].value = (document.getElementsByName('overig_prijs[]')[nr].value * (document.getElementsByName('materiaal_tot_verf_opp[]')[nr].value + document.getElementsByName('plaat_tot_verf_opp[]')[nr].value)).toFixed( 2 ) } } Form (in loop): PHP Code: <tr> <td><select name="overig_omsch[]" > <option></option> <option value=Engineering>Engineering</option> <option value=Inkoop bev.middelen>Inkoop bev.middelen</option> <option value=Inkoop snijwerk>Inkoop snijwerk</option> <option value=Spuiten>Spuiten</option> <option value=Stralen>Stralen</option> <option value=Transport>Transport</option> </select> </td> <td><select name="overig_eenh[]" onChange="overig_tot_abs(this, 0)" > <option></option> <option value="totaal">Totaal</option> <option value="kg">Per Kg</option> <option value="verf_opp">Per 1m2</option> </td> <td><input type="text" name="overig_prijs[]" size="10" value="" /></td> <td><input type="text" name="overig_totaal[]" size="10" style="text-align:right;background-color: #f1f1f1" value="" readonly="readonly" /></td> <td><input type="text" name="overig_opmerkingen[]" size="75" value="" /></td> </tr> I have a page that loads various "applications" into an iframe inside the main page. One of the applications loaded calls a javascript function that is loaded with the "application" page. It works great in Safari, Chrome & Firefox but error's out in IE8 - "Object doesn't support this action". Anyone know why ? Have other calls that work but this one is the only one that uses href Thanks, JerryB [CODE] <div id = 'trainingsubmitbutton' style='display:none;'><a href='javascript: submitdata(0)'>Submit This Record</a></div> [CODE] Hi, I need function for replacing one string with some html tag (for example <div>something</div>) in web page. Tricky is that in this replacing I must ignore all text between <a> and </a>. It's look easy but I am not good in javascript.
Hi, I'm just wandering, how can you stop the replace() function from replacing characters inside a word, such as, if I try to replace 'x' with 'and', then my string would go from 'example, x' to 'eandample, and'. Thanks in advanced 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. document.write(str.replace(/(\+|\(|\)|.|-|\/ /g,'')); feeble attempt to remove '.' '(' ')' ' ' '-' '/'and '+' Hi I am wondering if it is possible to replace a rating form with some sort of javascript star rating system that would submit the same way? Here is my current form: <form method=post action="%%%SCRIPT_URL%%%"> <input type=hidden name=main value="imageRate"> <input type=hidden name=file value="%%%FILENAME%%%"> <input type=hidden name=category value="%%%DIRECTORY%%%"> <select name=rate size=1> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> <option>8</option> <option>9</option> <option>10</option> </select> <input type=submit value="Rate This!"> </form> Right now it is a drop down menu and I would like to replace with a php, javascript, or ajax rating script that can keep the same properties. Any advice? I'm currently working at school on a website and I cycled through aloooot of tutorials, but I couldn't find anything >.< so the qeustion is how to make a VERY simple javascript div tag replacer using buttons. so if I click for example button 1 then I want div tag 1 replaced with div tag 2 and when you press button 2 div tag 1 or 2 gets replaced with div tag 3. the closest tutorial I found was: Replace one div with another Greetings, I am having trouble finding any examples to help me strip everything up to a certain character (the hypen) in a url. Hypothetical example below, as I only know how to accomplish this using a literal only for one url at a time but I need this for changing urls: Code: <script language="JavaScript"><!-- var temp = new String('http://www.site.com/abc_123_abc_-1379820930'); temp = temp.replace("http://www.site.com/abc_123_abc_-", ''); document.write(temp); //--></script> And I am hoping to be left with the series of numbers on the end. Any help is greatly appreciated. This is driving me nuts I need to replace all instances of "zz" with 'Z'. I can easily replace other strings such as a = a.replace(/mickeymouse/, "Z"); but a = a.replace(/zz/, "Z"); doesn't work. Must be a double characer thing? I was debugging my code looking for a loop. So in the process I added a confirm request and if the user clicked cancel I coded location.replace("Kill.html"). Problem was that the JAVASCRIPT continued to run until either it finished or I used the Task Manager to end the session. There3 was a small difference in browsers: Firefox put up the new screen while continuing to run the JAVASCRIPT while IE didn't put up the new screen until after the JAVASCRIPT was finished. I could tell the JAVASCRIPT was still running because the confirm messages kept popping up.
Hi, I need a javascript that detects flash and replace z-index value. i have 2 div. div1 (alternate HTML content) has z-index=-3 and div2 (flash object) z-index=0. If flash is detected, do nothing. if flash is not detected, i would like to set div1 z-index to a positive 3. can someone please help me? |