JavaScript - <div> Onclick Not Registering
i have a div that has a pointer cursor as the style. on click of the div, i'd like to change visibilities of some of my other divs, but i can't get it to run! can someone give me a push here? i think dw is telling me that there is an error in my code, but cant see it...
Code:
function getCP() { if (document.getelementbyid('apdiv11').innerHTML == "VIEW CONTROL PANEL") { document.getelementbyid('apdiv11').innerHTML = "BACK TO WEBSITE"; document.getelementbyid('wb_marquee1').style.visibility = 'hidden'; document.getelementbyid('apdiv6').style.visibility = 'visible'; } else { document.getelementbyid('wb_marquee1').style.visibility = 'visible'; document.getelementbyid('apdiv6').style.visibility = 'hidden'; } } Similar Tutorialshi all, my indexof() function is not being recognized when I enter an email address for an unsubscribe form I have on one of my pages. Additionally, the confirmation message is also not showing up when the email address IS valid. Here is my code that I am using on a PHP page: PHP Code: function Unsubscribe() { var IsValid = document.getElementById("email").value; alert(IsValid.indexOf("@")); exit; if (document.getElementById("email").value.length == 0 || IsValid.indexOf("@")) == -1) { alert("Enter a valid email address"); exit; } else { <?php $handle = @fopen("../logs/unsubscribes.txt", "a"); fputs($handle, $_POST["email"] . " " . "\r\n"); fclose ($handle); ?> alert(IsValid &&" has been unsubscribed."); <?php if (! $_POST["email"]) { //DO NOTHING } else { header("Location: http://www.google.com/"); } ?> } } //--> </script> </head> <body> <form action="" method="post" name="frm" onsubmit="Unsubscribe()"> <center><br /> Enter Your Email Address:<br /> <input type="text" id="email" name="email" /> </center> <p> <label> <center><input type="submit" id="unsubscribe" value="Unsubscribe Me" /></center> </label> </p> </form> </body> </html> to those PHP experts, I am aware of the RegEx function for validation, but I don't understand it, which is why I don't use it (in case anyone points that out). The other thing that is problematic is that the PHP code is automatically using HEADER() regardless of "email"'s value Hi everyone, this is my first post here and I hope that you can be of assistance!! I have an issue with a registration form. What I would like to do is only allow a certain email domain in the 'email' field. Eg. Only allowing @gmail.com email addresses, and all others would receive an error. This is the line of code that I believe needs changing: function isEmail(valor){if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(valor)){return(true)}else{return false;}} I am not too familiar with this but through my hours of research, I believe that I need to add something to this line. Thanks in advance. I'm currently working on a project and I am doing a bunch of image switching. I'm having a problem with the following... I have seven medium image objects and one small one. One is at the top and the other 7 are below. When one of the 7 is clicked, it then becomes the one up top and the one up top then takes the place of the image clicked. This needs to be able to happen no matter which of the seven i click. Also when you click one of the seven it runs a script to change 9 other images in the center of the page. this isnt too important because i have it working already. What i have is, each of the seven images run their function that changes the 9 center images and then it runs another function. What i need is for that function to determine which company for example(shaws, lowes, target) the top image belongs to and replace the image that was clicked with the top one. But i also need to replace the NAME="" and ONCLICK="function()" with the proper ones for the original company up top. Please if you can understand what im trying to do let me know, if you need further clarification i can do so. i can draw a picture of what im trying to do or the layout if needed but i cant necessarily show anyone the project due to a non-disclosure. Is it possible disable an onclick after clicking it and then enable it from another onclick by id Code: <img id="one" href="images/homepage/sliders/bonus_button.jpg" style="position:relative; top:30px; left:50px; height:30px; width:70px; float:left;"> This code runs when it is clicked: Code: $("#one").click(function() { runEffectB(); return false; }); What I would like to happen is for either runEffectB() to not run if it was just run or to disable the #one.click once it has run. I am assuming I will be able to re-enable it from another onclick running a similar function. This is jquery and jquery ui if that helps. Any ideas much appreciated. Hey guys, OK, so I have two buttons (code below) that when a user clicks on it, it will place text in a textarea. You can view all the code below: Buttons: Code: <div id="newButton"> <a href="#"><img src="http://i49.servimg.com/u/f49/17/29/94/19/graphi10.png" alt="Request a Graphic"></a> <a href="#"><img src="http://i49.servimg.com/u/f49/17/29/94/19/review11.png" alt="Request a Review"</a> </div> The textarea ID is: Code: text_editor_textarea and this is the code that I would like to be placed inside the textarea: Code: Nature of Request: Creation Size: Primary Colors: Text To Insert: Donation: Extra Information: URL: I tried this, but the BBCode would not keep it's structure and would all end up on one line. EDIT: Oh...The BBCode is parsing inside the code box >.< hi everybody.. i have this simple code: Quote: <html> <head> <script language="javascript" type="text/javascript"> document.write("<input type='button' value='push' onclick='hi()'/>"); function hi() { alert("hi"); document.write("<input type='button' value='enter' onclick='javascript: bye()'/>"); } function bye() { alert("bye"); } </script> </head> <body> </body> </html> if i try to run it on chrom its works well.. but on IE or FireFox its not define the bye() function.. whats the reason?! and how i can solve it?.. thanks very much.. Hi i have a page that allows the user to enter details and also upload an image , I have onclick event on a submit button that goes off and performs a geocode on the postcode and saves the lat long to a database along with the other details they enter ( which all works fine) . The problem is that when i use the onclick event with the submit button it seems to bypass the onclick JS function and just go straight to the image upload bit. Can a button be a submit button and also have an onclick event or is there anything else i can do to fix the problem? Hello... Here is an example of a site I'm working on: http://mrmatthewreese.com/surine/custominlays.php notice the links for the alien cross bones, celtic knot etc...change colors once they are clicked on? Is it possible to have the top (alien crossbone) be set to black before it is clicked on then changed to the grey color once a different link is clicked? Just curious if anyone can help. Here is the javascript code: <script language="JavaScript" type="text/javascript"> /*<![CDATA[*/ var Lst; function CngClass(obj){ if (Lst) Lst.className=''; obj.className='boldlink'; Lst=obj; } /*]]>*/ </script> <a href="#" onclick='changeimage();'><span onclick="CngClass(this);">Alien Crossbones</span></a><br /> <a href="#" onclick='changeimage2()'><span onclick="CngClass(this);">Celtic Knot</span></a><br /> <a href="#" onclick='changeimage3()'><span onclick="CngClass(this);">Compass Rose</span></a><br /> <a href="#" onclick='changeimage4()'><span onclick="CngClass(this);">Fleurdelis</span></a><br /> <a href="#" onclick='changeimage5()'><span onclick="CngClass(this);">Geometrix</span></a><br /> <a href="#" onclick='changeimage6()'><span onclick="CngClass(this);">Modern Vine</span></a><br /> <a href="#" onclick='changeimage7()'><span onclick="CngClass(this);">Nouveau</span></a><br /> <a href="#" onclick='changeimage8()'><span onclick="CngClass(this);">Scorpion</span></a><br /> <a href="#" onclick='changeimage9()'><span onclick="CngClass(this);">Traditional Block</span></a><br /> <a href="#" onclick='changeimage10()'><span onclick="CngClass(this);">TrebleBass Clef</span></a> <a href="#" onClick="showClubs(<% Response.Write x_ID_Nanny %>);" > Now this showclubs function shows a hidden div and at the end I have a return:false; but when you click on the link - it still seems to reload to the page and take you to the top how can I get it to just show the div without seeming to reload the page? Hey. When a checkbox is checked, I want it to add the id number of what I've got in a PHP variable, to appear in a <input type="text" />. For example: The id is 1, 2, and 3. So 3 checkbox's. I click on the first, and it adds to another input field, '1'. I hit the second, and the same thing happens, except the id is 2. Of course, I know how to do the ID and all with PHP. All I need to do now, is where when you click a check box, it adds to another field, and adds & after every check. Here is my code: Code: <input type="checkbox" name="delete" onclick="this.checkedbox.style.display=(this.value=='checked' ? 'inline' : '2' )" /> <input type="text" name="checkedbox" /> Thanks. I need a code that makes the following: 1. I need a link to a certain website 2. If someone click that link it opens in new tab and it makes 1. link invisible and show a another link on the same place with a time delay of 5 seconds Hi Guys I have been trying to implement a way of using `onclick` to fill out a form field, with a Value assigned by a clickable rollover image. So i have a image rollover of a PC, i give the PC a Value? ID? of `PC No34` When the image is clicked it updates its Value of PC No34 to a Form text field which is named `pcid` the Form is on the same page as the PC rollover image. I have been trying most of the day but not getting it. Pls help Thanks for any help with this Willo Hi I have this code which works fine: Code: <td class="Content_TD" onclick="_gaq.push(['_trackEvent', 'navigation ', 'link', 'blocks']); window.open('http://www.google.dk/');"> But I dont now the parameters instead of window.open, if I want it to open on top. Can somebody please help me? Thanks in advance Claus Hi there Looking at adding a sound file to a game to play when an image, a .png image is pressed.. it will be a simple 1sec (or less) sound file i.e. bell, whistle etc. Just looking at some help on where to start with the code. Many thanks LL Hi, I have created the following text input field: Code: <form name="xyz"> <input type="text" name="myText" size="30" value="Initial text" onclick="document.xyz.myText.value='';"/> </form> When the field is clicked the initial text is removed, clearing the way for new text to be entered, which is what I want. The trouble is if the field is again clicked the new text entered is also cleared which is not what I want. I only the field cleared for the first click and not for subsequent clicks. How can this be achieved? I will be grateful for all help. I am attempting to have a link hide and unhide a div It works in Chrome and Firefox, but not in IE The only thing that does not work is when i click it, it dosen't unhide or change the title, so basically, function unHide is not running, although there are no errors thrown. I have this in the top of the page Code: document.getElementsByClassName = function(className){ var hasClassName = new RegExp("(?:^|\\s)" + className + "(?:$|\\s)"); var allElements = document.getElementsByTagName("*"); var results = []; var element; for (var i = 0; (element = allElements[i]) != null; i++) { var elementClass = element.className; if (elementClass && elementClass.indexOf(className) != -1 && hasClassName.test(elementClass)) results.push(element); } return results; } function hider(){ var eles = document.getElementsByClassName('hider'); for(var i = 0; i < eles.length; i++){ var theid = eles[i].id; eles[i].innerHTML = "<div style='display:block; text-decoration:none; color: black; clear:both; text-align:right; float:right; margin-top:-40px; margin-right:3px;' class='open'><a href='#' onClick=\"unHide('" + theid + "'); return false\" > Click To Open </a></div><div class='hides'> " + eles[i].innerHTML + "</div>"; } } function unHide(a){ var eles = document.getElementById(a); str = eles.innerHTML; if(str.search("> Click To Open <") == -1){ str = str.replace("> Click To Close <", "> Click To Open <"); str = str.replace("class=\"nothides\"", "class=\"hides\""); } else{ str = str.replace("> Click To Open <", "> Click To Close <"); str = str.replace("class=\"hides\"", "class=\"nothides\""); } eles.innerHTML = str; } and i have this where i want it to display and hide the section Code: <h4 onclick="unHide('editB')">Edit This Property</h4> <div id='editB' class='hider'> ... </div> The way it works is that it reads the page for all objects with the class name "hider" then it inserts two divs into "hider", one of them is a title that says: "click to open" and the other div has a class of "hides" that is set to display:none Once "click to open" is clicked, it uses .replace to find "click to open" and class=hide and change them to "Click to Close" and class=nothides if it is clicked again, it does the opposite. i just need to know why it isn't working in IE. Thanks in advance With input box if you type something and refresh the page, the previous words that you typed in will be filtered and be display in a scroll down form in which you can click it. My question is, when I click the input type is it possible to scroll down, and display values that comes from a database? It should also filter the scroll down results. If it's possible I don't know how to do it. I tried googling but I can't find an explanation on how to do it. Thanks. <input type="text" value="" onclick=""> Hello, I am trying to use the onclick function to allow a user to change the color of a photo. Everything works but I need a more practical way than using a bunch of IF statements. Here is what I have so far. This is just the function part I can include it all if needed. Code: function changeImage(c_img) { if(c_img == "cameo") { document.images("changingImage").src = "content/Image/Cameo.jpg"; } else { document.images("changingImage").src = "content/Image/GreenChili.jpg"; } Now I need to add 12 more imgs to this. It works if I throw 12 more if(c_img...)but there must be a better way. I am kinda a newbie when it comes to Java.. Thanks for any advice. Hi there, Does anyone know how you might use the onclick event to type a letter from the keyboard? <img src="images/a.jpg" onclick="keyCode==96" /> Something like this? Many Thanks hey, im pretty much a newbie at scripting period, just a quick question. i know how to do a basic onclick function and how to add multiple functions, but is there a way i can make it so that way the onclick function only happens if the form its in returns true? (The onclick function is within the submit button of the form).
|