JavaScript - Javascript Class Onclick Links
Okay. So here's what I'm trying to do. I have my landing page to my site and near the bottom I have 4 little 48x48 class divs (for social network link images if you were wondering ). Each Class div has a background style all to it's own. (so in this case 4 different divs with 4 different class names) .
What I want to do with the javascript is to have a function(s) that when called on (depending on which div.class was/is clicked on) will open up a lightbox/new page containing the new page (pertaining to the appropriate social network, depending on which class has been clicked on). I don't want to put an <a></a> tag around the div.classes themselves seperately because the landing page itself has 8 different styles, plus the div.classes I would have to hunt down within the site itself. haha Basically in short I want the classes to have seperate links that when clicked upon it calls the function, opens the lightbox (or opens the new tab/page) and loads the appropriate page. Think yall can help me out here? Similar TutorialsI hate javascript.... OK, here's my latest challenge with Javascript. I recently went into twp php files and made a few very minor changes to some outdated $date functions. Now, I have three small icons for 'copy', 'paste','delete' using the javascript 'onclick' function that have stopped working. In fact, when I replace the two recently revised files with the originals, these icons no longer work there either. Any help would be appreciated. I'm simply at a total loss for ideas here. From the primary php file is the relevant lines of source code....As far as I can tell, the second paragraph in each area is returning a 'null' value; i.e. o1a.options.selectedIndex is null. Code: function aCopy(dt){ o1a = document.getElementById("avail_1a_" + dt); o1b = document.getElementById("avail_1b_" + dt); o2a = document.getElementById("avail_2a_" + dt); o2b = document.getElementById("avail_2b_" + dt); o3a = document.getElementById("avail_3a_" + dt); o3b = document.getElementById("avail_3b_" + dt); avail_1a = o1a.options.selectedIndex; avail_1b = o1b.options.selectedIndex; avail_2a = o2a.options.selectedIndex; avail_2b = o2b.options.selectedIndex; avail_3a = o3a.options.selectedIndex; avail_3b = o3b.options.selectedIndex; } function aPaste(dt){ o1a = document.getElementById("avail_1a_" + dt); o1b = document.getElementById("avail_1b_" + dt); o2a = document.getElementById("avail_2a_" + dt); o2b = document.getElementById("avail_2b_" + dt); o3a = document.getElementById("avail_3a_" + dt); o3b = document.getElementById("avail_3b_" + dt); o1a.options.selectedIndex = avail_1a; o1b.options.selectedIndex = avail_1b; o2a.options.selectedIndex = avail_2a; o2b.options.selectedIndex = avail_2b; o3a.options.selectedIndex = avail_3a; o3b.options.selectedIndex = avail_3b; } function aDelete(dt){ o1a = document.getElementById("avail_1a_" + dt); o1b = document.getElementById("avail_1b_" + dt); o2a = document.getElementById("avail_2a_" + dt); o2b = document.getElementById("avail_2b_" + dt); o3a = document.getElementById("avail_3a_" + dt); o3b = document.getElementById("avail_3b_" + dt); o1a.options.selectedIndex = 0; o1b.options.selectedIndex = 0; o2a.options.selectedIndex = 0; o2b.options.selectedIndex = 0; o3a.options.selectedIndex = 0; o3b.options.selectedIndex = 0; From the supporting php file are the following lines of code.... Code: $s .= "<td nowrap=nowrap class=calendar style='border-left:1px dashed #000;'>"; $s .= "<a href='javascript:void(0);' onclick=\"aCopy('$year-$month-$d');\"><img src='../admin/_calendar/Copy.gif' alt='Copy Availability' width='16' height='16' border='0' /></a>"; $s .= " <a href='javascript:void(0);' onclick=\"aPaste('$year-$month-$d');\"><img src='../admin/_calendar/Paste.gif' alt='Paste Availability' width='16' height='16' border='0' /></a>"; $s .= " <a href='javascript:void(0);' onclick=\"aDelete('$year-$month-$d');\"><img src='../admin/_calendar/Delete.gif' alt='Delete/No Availability' width='16' height='16' border='0' /></a>"; $s .= "</td>"; None of these lines of code were changed or altered when I was updating the code. Any thoughts or suggestions would be deeply appreciated? Talltom hi all, I am using ajaxcontent javascript to load content into certain parts of the website and all my links work that way.. the problem with that is that I can't use classical approach for building menus.. like when you assign "current " class to your link and then it changes color or whatever when you follow link to another html or whichever website. So I have menu like this .. Code: <li class="current"><a href="index.htm"><b>One</b></a></li> <li><a href="javascript:ajaxpage('2.php', 'right');"><b>Two</b></a></li> <li><a href="javascript:ajaxpage('3.php', 'right');"><b>Three</b></a></li> <li><a href="javascript:ajaxpage('4.php', 'right');"><b>Four</b></a></li> <li><a href="javascript:ajaxpage('5.php', 'right');"><b>Five</b></a></li> I'm sorry for my English is so bad.. but I will try to explain what I'd like to achieve.. I'd like to put in some kind of onclick script which will change class of that <li> to current but at the same time I want to change <li class="current"> to <li class=""> or <li class="whatever">... so here I go again.. Code: <li class="current"><a href="index.htm"><b>One</b></a></li> <li><a href="javascript:ajaxpage('2.php', 'right');"><b>Two</b></a></li> <li><a href="javascript:ajaxpage('3.php', 'right');"><b>Three</b></a></li> <li><a href="javascript:ajaxpage('4.php', 'right');"><b>Four</b></a></li> <li><a href="javascript:ajaxpage('5.php', 'right');" onclick="this.className='current'"><b>Five</b></a></li> Now this changes the <li> class to current and I only want to have 1 current. In this case link "Five" should have current class others should have no class or class="whatever" its same Thank you for any answers in advance Hi, is it possible to change the class of an element onClick with a fade? This is the code I have so far which works great for changing the class but I have no idea how to include a fade in this. I am changing the class in order to change the background-image of a div. Code: <a href="#none" onclick="document.getElementById('tool').className ='tool1'"> Many thanks, M The very basic onclick code I threw together: Code: function descw() { document.getElementById("desc").style.display="block"; } function descc() { document.getElementById("desc").style.display="none"; } The div that needs a description... Code: <div class="select"><img src="image.jpg" onclick="descw()"></div> ..and the actual description div. Code: <div id="desc"> <img src="close.jpg" onclick="descc"> <p>Description</p> </div> This works, but I have a whole class of divs named select that need their own individual description divs. Id method is okay for one div apparently, but if I click on others it loads the first description div. What do I use instead? I tried getElementsByName and Atrribute and got an error. Hey all, Hoping someone could help me out with some javascript coding as I am a complete novice to this! I am currently building a website using 1 static page and all the content will be pulled in through different iframes by clicking on a navigation on the page. I found a very handy piece of javascript coding that lets me remove a class from one link and move it to the link that was clicked on (the code will be below). The issue I am facing with this is that if I have Home set to class="On" to begin with and then click on Location, the background image will be added to the Location section but won't get removed from Home until it is physically clicked on. Can anyone help me out with how I can get this to work correctly? javascript: Code: <script language="JavaScript" type="text/javascript"> var Lst; function CngClass(obj){ if (typeof(obj)=='string') obj=document.getElementById(obj); if (Lst) Lst.className=''; obj.className='On'; Lst=obj; } </script> HTML: Code: <div id="navWrapper"> <div id="globalNav"> <ul> <li onclick="CngClass(this);" class="On"><a href="iframes/home.html" target="content_iframe">Home</a></li> <li onclick="CngClass(this);" class=""><a href="iframes/location.html" target="content_iframe">Location</a></li> <li onclick="CngClass(this);" class=""><a href="iframes/speakers.html" target="content_iframe">Speakers</a></li> <li onclick="CngClass(this);" class=""><a href="iframes/agenda.html" target="content_iframe">Agenda</a></li> <li onclick="CngClass(this);" class=""><a href="iframes/useful_material.html" target="content_iframe">Useful Material</a></li> <li onclick="CngClass(this);" class=""><a href="iframes/event_presentations.html" target="content_iframe">Event Presentations</a></li> <li onclick="CngClass(this);" class=""><a href="iframes/gallery.html" target="content_iframe">Gallery</a></li> </ul> </div> <div id="localNav"></div> </div> I have a parent div, that when hovered over changes the background color. There is a onclick event so that a user can click anywhere within the div for the link to work. Inside that div I have another div with unique links. When I click on any of those links, it also activates the other onclick event. I don't want this. :-/ Here is my code Code: <div class="cat1" onmouseover="style.backgroundColor='#09F'; this.style.cursor='pointer';" onmouseout="style.backgroundColor='';" OnMouseUp="location.href='http://a.com/details.php?id=305366';"> <div class="itemwrapper"> <div class="datebox">Wednesday - January 3rd, 2007</div> <div class="timebox">08:00am - 08:30am</div> <div class="subbox">Blah</div> <div class="peoplebox"><a href="mailto:a@aol.com">George</a></div></div> </div> I'm guessing I need to create some type of function that will detect where the click came from and then decide whether to fire it or not? Thank you in advance for your help. This script is activated with a onclick event in a link, the box appears and disappears, the problem is I have two links, I would like to disable Box 1 If I click Box 2 and viceversa. Any help??? Code: <script language="javascript"> var state = 'hidden'; function showhide(layer_ref) { if (state == 'visible') { state = 'hidden'; } else { state = 'visible'; } if (document.all) { //IS IE 4 or 5 (or 6 beta) eval( "document.all." + layer_ref + ".style.visibility = state"); } if (document.layers) { //IS NETSCAPE 4 or below document.layers[layer_ref].visibility = state; } if (document.getElementById && !document.all) { maxwell_smart = document.getElementById(layer_ref); maxwell_smart.style.visibility = state; } } //--> </script> <!-- HIDDEN BOX 1 TO BE SHOWN ONCLICK --> <div id="box_1" style="position:absolute; top:85px; left:12px; visibility:hidden; width:510px; background-color:#BCD2E1; padding-left:4px; padding-right:4px; padding-bottom:4px;"> BOX 1 </div> <!-- END - HIDDEN 1 BOX TO BE SHOWN ONCLICK --> <!-- HIDDEN BOX 2 TO BE SHOWN ONCLICK --> <div id="box_2" style="position:absolute; top:85px; left:12px; visibility:hidden; width:510px; background-color:#BCD2E1; padding-left:4px; padding-right:4px; padding-bottom:4px;"> BOX 2 </div> <!-- END - HIDDEN BOX 2 TO BE SHOWN ONCLICK --> <a href="javascript://" onclick="showhide('box_1');">BOX 1</a> | <a href="javascript://" onclick="showhide('box_2');">BOX 2</a> Hiya! Trying to figure out how to use javascript to extract all links on a page that have a certain class: e.g. - extract only links with a class of 'tools', ignore all other links: Code: <a href="http://www.google.com" class="tools">Search</a> <a href="http://www.tripod.com" class="grapes">Searched</a> <a href="http://www.dogpile.com">Searches</a> Any help would be appreciated, I'm guessing I probably have to use something like getelementbyclass("tools")? Hey everyone, I am having troubles with my form not working correctly in IE. I have onclicks for different parts of my site. I am trying to use onclick and divs to make this happen. Can some look at my code and help me out? Thanks/ Code: <script type="text/javascript"> function switchFS(obj) { var fset,i,fsclass; fset=document.getElementsByTagName('fieldset'); fsclass = obj; for ( i=0; i<fset.length; i++) { if ((fset[i].getAttribute('class') != "user") && (fset[i].getAttribute('class') != fsclass)) { fset[i].style.display = "none"; } else { fset[i].style.display = "block"; } } } </script> </head> <body id="submitform"> <div id="container"> <div id="header"> <?php include($dirprefix . "external/include/header.html"); ?> </div><!-- end header --> <div id="maincontent"> <h3> </h3> <?php include($dirprefix . "external/include/menu_inactive.html"); ?> <div id="bodycontent"> <div id="bodyleftcol"> <h4>Contact</h4> <h5>Registration</h5> </div> <div id="bodyrightcol"> <h1 class="formhead">Site Registration</h1> <p>Please register if you are a Zimmer customer, or an agency or designer working on behalf of one. Completing the requested information will enable us to continue to update and improve site content. Please make note of your password for future reference. You will receive an email with your login information.</p> <div id="mainrightcol"> <form name="form" id="register" method="post" action="processregister.php"> <fieldset class="user"> <legend>i am a:</legend> <label><input type="radio" value="Healthcare provider" class="checkbox" name="usertype" onclick="switchFS('healthcare');" /> Healthcare provider</label> <label><input type="radio" value="Agency or designer for a customer" class="checkbox" name="usertype" onclick="switchFS('agency');" /> Agency or designer for a customer</label> <label><input type="radio" value="Independent agency or designer" class="checkbox" name="usertype" onclick="switchFS('agency');" /> Independent agency or designer</label> <label><input type="radio" value="Zimmer employee" class="checkbox" name="usertype" onclick="switchFS('zimmer');" /> Zimmer employee</label> <label><input type="radio" value="Zimmer field representative" class="checkbox" name="usertype" onclick="switchFS('zimmer1');" /> Zimmer field representative</label> <label><input type="radio" value="Media" class="checkbox" name="usertype" onclick="switchFS('user');" /> Media</label> <label><input type="radio" value="Healthcare Author/Publisher" class="checkbox" name="usertype" onclick="switchFS('author');" /> Healthcare Author/Publisher</label> <label><input type="radio" value="Other" class="checkbox" name="usertype" onclick="switchFS('user');" /> Other</label> </fieldset> <fieldset class="zimmer" style="display: none;"> <legend>zimmer information</legend> <!--<label for="businessunit">Zimmer business unit: <input type="text" name="businessunit" value="" required="required" /></label>--> <label for="division">Zimmer business unit: <select name="division"> <option value="">- n/a -</option> <option value="Knees">Knees</option> <option value="Hips">Hips</option> <option value="Extremities">Extremities</option> <option value="Trauma">Trauma</option> </select></label> </fieldset> <fieldset class="zimmer1" style="display: none;"> <legend>zimmer information</legend> <!--<label for="businessunit">Zimmer business unit: <input type="text" name="businessunit" value="" required="required" /></label>--> <label for="distributorship">Zimmer distributorship: <input type="text" name="distributorship" value="" required="required" /></label> </fieldset> I have added the javascript and the section of code where the user picks how they are. Once you click on one of the users in IE the form goes away. I am trying to set a PHP variable but am using the onClick() event handler, which requires JavaScript. See below: [ICODE]<a href="javascript:update('gallery/Fgallery1-1.jpg', 0);" onClick="index_value = 'gallery1-1';"> <img src="gallery/gallery1-1.jpg" alt="Antique Impressions Hardwood Flooring - White Oak" border="0" class="galborders" onMouseOver="alert_msg('Click to view image close up')" onMouseOut="away()"></a><br /></ICODE] The webpage is http://www.hardwood-floor-products.com/gallery1.php. What I am trying to do is to set up a PHP variable, $index, that is equal to "gallery1-1', 'gallery1-2', etc. so that I can use that varialble throughout this module. I also realize that I need to use JavaScript with onClick() but I have had no success. I realize that PHP is servier-side and JavaScript is client-side, but there must be a way to do that. Genia Hi everyone, I'm a JavaScript newbie and am trying to use it to direct users to a search page based on the values of two drop down boxes. The issue i am having is that the code below works fine on a test page, but not on my test domain (with wordpress theme) and so i was wondering whether there is anything I am doing wrong... Is onclick already defined maybe? I'm not sure how it works to be honest... Code: <script type="text/javascript"> function gosearch() { var breed = document.getElementById('breed').value; var area = document.getElementById('area').value; var site = "http://hairloss-help.net/?s="; var searchurl = site + breed + area; window.location.href = searchurl; } </script> <strong>Breed</strong> <select name="breed" id="breed"> <option value="">> All</option> <option value="Affenpinscher+">Affenpinscher</option> <option value="Afghan+Hound+">Afghan Hound</option> <option value="Airedale+Terrier+">Airedale Terrier</option> <option value="Akita+">Akita</option> <option value="Alaskan+Malamute+">Alaskan Malamute</option> <option value="Alsation+">Alsation</option> <option value="American+Cocker+Spaniel+">American Cocker Spaniel</option> <option value="Anatolian+Karabash+">Anatolian Karabash</option> </select> <strong>Area</strong> <select name="area" id="area"> <option value="all">> All Areas</option> <optgroup label="England"> <option value="Avon">Avon</option> <option value="Bedfordshire">Bedfordshire</option> <option value="Berkshire">Berkshire</option> <option value="Bristol">Bristol</option> <option value="Buckinghamshire">Buckinghamshire</option> <option value="Cambridgeshire">Cambridgeshire</option> <option value="Cheshire">Cheshire</option> <option value="Cleveland">Cleveland</option> <option value="Cornwall">Cornwall</option> </select> <input type="button" name="gobutton" id="gobutton" value="Go!" onclick="gosearch();" /> The domain I'm currently testing this on is http://www.hairloss-help.net. Any help would be much appreciated. Thanks Sam i have this line in my code: PHP Code: echo '<a href="" onClick="yesnolist()">Free Chat</a>'; then at the top i have: Code: <? php //have some php here ?> <div class="innerContainer"> <head> <script type="text/JavaScript"> function yesnolist(val) { alert("lakjsd"); var e = confirm('Do you want to send a free chat request?'); if (e == true) { window.location.href = "http://www-rainbowcode-mobi/confirmfreechat.php"; window.location('http://www-rainbowcode-mobi/confirmfreechat.php'); return true; } else return false; } </script> </head> <span class="headings2">CONTACTS</span> //and more code after this echo '<a href="" onClick="yesnolist()">Free Chat</a>'; why is it not doing my onClick()?? please help? thanks Hi guys. I have made a PHP script that queries a database and uses the reponse to display multiple radio boxes (using a while loop). What I would like to do is have the page URI updated when a radiobox is clicked, without the user having to press on a "Submit" button or something. This is where Javascript comes into play. As this is a while loop, there is no specific number of responses or prefixed names. I've found a lot of stuff on Google with functions calling ID's, and then if the ID matches do a predefined response. Of course that wouldn't work in this situation, and to be frank I don't need anything near as complex. What I'm looking to do is call a Javascript function to redirect the page to "...?location=<get location from PHP var>&id=<get ID from checkbox ID/name>". When the page reloads, I can then use the PHP $_GET["id"] function to display data. It sounds SO simple in theory! Can anyone help? What i've done (and failed): Code: echo "<form>"; while ($explode_count_dec > "0"): $while_query = mysql_query("SELECT * FROM printers WHERE ID LIKE '$explodedata[$explode_number]'"); $while_result = mysql_fetch_assoc($while_query); echo "<input type='radio' value='".$explodedata[$explode_number]."' name='printer' onClick='showmore(".$explode_number.")' />".$while_result["Model"]." <BR /> "; ++$explode_number; --$explode_count_dec; endwhile; echo "</form>"; and the JS: Code: <script type="text/javascript"> function showmore($text) { var room = "<?= $get_location; ?>"; window.location = "?location=" + room + "&id=" + <?php $text; ?> // Couldn't do just $text here? I wish I knew JS.. } </script> I assum the following html code: <div id="id1" onclick="click()">A<div> <div id="id2" onclick="click()">B<div> Do you know how to get ID = id2 when I onclick on A? Hi Everyone, Iv got a button in my HTML5 document that when clicked gives an error. The button is coded as follows: Code: <input type="button" onclick="startGame();" value="Play!" /> The startGame function is held in an external JavaScript file. Whenever i run the code and click on the button i get an error that says startGame is not defined. Any ideas? Thanks, Luke Hi, i have several links which i am trying to add an on click command to which copies a certain code to the clip board so the user can paste the code with out having to manually copy it first. i have this Code: $latest = simplexml_load_file('codes_ending_soon.xml'); foreach ($latest->discount as $discount) { $code = $discount->id; $link = $discount->link; $store = $discount->storeName; $logo = $discount->logo; $details = $discount->details; if($code_count <=4) {?> <div class="code_cont"> <div class="code_logo"><img src="<?php echo $logo?>" alt="<?php echo $store." code"?>" title="<?php echo $store." code"?>" height="32" /></div> <a class="code" href="<?php echo $link?>" title="Click to see related product(s) / retailer and apply code" onclick="window.clipboardData.setData(<?php echo $code?>)"><?php echo $code?></a> <div class="description"><?php echo $details?></div> </div><?php $code_count++; } }?> but when i click on the link nothing seems to copy at least in firefox anyway? can anyone help me please thanks Luke I'm attempting to modify a facebook app I purchased that allows friends to send gifts to each other. The problem with the program is that when gifts are accepted, they continue to show on the "accept gift" page. I'd like to change it so that after gifts are accepted, they no longer show on that page, preventing the user from wondering "which gifts have I already accepted?" Later, I'd like to also create a reject gift option, but 1st things 1st. The program is written in php, html, and javascript. I decided one solution was to add a new empty column to the sql table called "accepted". When the user presses "accept gift" I'm thinking an onclick event could be used to add a "y" (for yes) to that record in the database. Then modify the code that displays the gifts to only show gifts from the table 'WHERE' accepted is equal to null. My questions a Is this a logical approach? If so, is the process: create a javascript function that updates mysql and call that function with an onclick event? What about sql injection vulnerabilities? I've read a lot about ajax and HTTP request being the way to do things like this, but could not find an example that represented what I want to do. After weeks of reading, I'm still lost. hello everyone, i am new to all this.. i need help regarding.. i am generating text box dynamically(mean it's a multiple select box, depending upon the number you select , it will generate that many text field.) my problem is that i want to assign a calender to the text field generated whenever a user clicks on that text field. i am able to do it for simple text field as onclick="javascript: showCalendar('idname')" but how to do it in this case, where can i declare this ? Hi, I want to call a javascript function without having a button click and it is nestled within php. I have the function OpenChat() in my main page - this works fine. I have the below sub page that is called by an onclick event (originally I had the script launch through a button but I am over loading my server at the moment and need to find a different way to call the function). So I tried the below, which doesn't work. The function just isn't working. My script is: PHP Code: <?php session_start(); if (!(isset($_SESSION['login']) && $_SESSION['login'] !='')){ header ("Location: Welcome.php"); } $SMyPId=$_SESSION['MyPId']; include("dbconnect.php"); $result = mysql_query("SELECT (chatterspace) FROM chat WHERE chatter='{$SMyPId}' AND EndDate IS NULL group by chatterspace"); while($row = mysql_fetch_array($result)){ $oak = $oak . ';' . $row['chatterspace']; } $beach=explode(";",$oak); $divonecount=$beach[1]; $divtwocount=$beach[2]; $divthreecount=$beach[3]; $divfourcount=$beach[4]; $divfivecount=$beach[5]; if($divonecount=='chat1'){ $chat1='full'; }else if($divtwocount=='chat1'){ $chat1='full'; }else if($divthreecount=='chat1'){ $chat1='full'; }else if($divfourcount=='chat1'){ $chat1='full'; }else if($divfivecount=='chat1'){ $chat1='full'; }else if($divonecount=='chat2'){ $chat2='full'; }else if($divtwocount=='chat2'){ $chat2='full'; }else if($divthreecount=='chat2'){ $chat2='full'; }else if($divfourcount=='chat2'){ $chat2='full'; }else if($divfivecount=='chat2'){ $chat2='full'; }else if($divonecount=='chat3'){ $chat3='full'; }else if($divtwocount=='chat3'){ $chat3='full'; }else if($divthreecount=='chat3'){ $chat3='full'; }else if($divfourcount=='chat3'){ $chat3='full'; }else if($divfivecount=='chat3'){ $chat3='full'; }else if($divonecount=='chat4'){ $chat4='full'; }else if($divtwocount=='chat4'){ $chat4='full'; }else if($divthreecount=='chat4'){ $chat4='full'; }else if($divfourcount=='chat4'){ $chat4='full'; }else if($divfivecount=='chat4'){ $chat4='full'; }else if($divonecount=='chat5'){ $chat5='full'; }else if($divtwocount=='chat5'){ $chat5='full'; }else if($divthreecount=='chat5'){ $chat5='full'; }else if($divfourcount=='chat5'){ $chat5='full'; }else if($divfivecount=='chat5'){ $chat5='full'; } $result = mysql_query("SELECT * FROM allusers WHERE PId='{$mulberry}'"); while($row = mysql_fetch_array($result)){ $nosegay=rand(). rand(). rand(). rand(). rand(); $nightshade="{$SMyPId};{$mulberry};{$row['fullname']};{$nosegay}"; $elm=$row['pphoto']; $helmlock=$row['fullname']; } $poplar=$_POST['chat']; if($chat1 !=='full'){ echo '<script type="text/javascript"> function This(){ OpenChat(\'chatheader1.php\',\'chat1\',\'chat=' . $poplar . '\',\'ChatID=0\',\'getDisplayChat1.php\',\'ChatDisplayOne\',\'getThisChat1.php\',\'displaytalkOne\',\'artemis=' . $poplar . '\')"; alert("chat1"); } </script>'; }elseif($chat2 !=='full'){ echo '<script type="text/javascript"> function This(){ OpenChat(\'chatheader2.php\',\'chat2\',\'chat=' . $poplar . '\',\'ChatID=0\',\'getDisplayChat2.php\',\'ChatDisplayTwo\',\'getThisChat2.php\',\'displaytalkTwo\',\'artemis=' . $poplar . '\')"; alert("chat2"); } </script>'; }elseif($chat3 !=='full'){ echo '<script type="text/javascript"> function This(){ OpenChat(\'chatheader3.php\',\'chat3\',\'chat=' . $poplar . '\',\'ChatID=0\',\'getDisplayChat3.php\',\'ChatDisplayThree\',\'getThisChat3.php\',\'displaytalkThree\',\'artemis=' . $poplar . '\')"; alert("chat3"); } </script>'; }elseif($chat4 !=='full'){ echo '<script type="text/javascript"> function This(){ OpenChat(\'chatheader4.php\',\'chat4\',\'chat=' . $poplar . '\',\'ChatID=0\',\'getDisplayChat4.php\',\'ChatDisplayFour\',\'getThisChat4.php\',\'displaytalkFour\',\'artemis=' . $poplar . '\')"; alert("chat4"); } </script>'; }elseif($chat5 !=='full'){ echo '<script type="text/javascript"> function This(){ OpenChat(\'chatheader5.php\',\'chat5\',\'chat=' . $poplar . '\',\'ChatID=0\',\'getDisplayChat5.php\',\'ChatDisplayFive\',\'getThisChat5.php\',\'displaytalkFive\',\'artemis=' . $poplar . '\')"; alert("chat5"); } </script>'; }else{ echo '<script type="text/javascript"> function This(){ alert("You have reached your IM capacity, please close a chat box"); } </script>'; } mysql_close($con); ?> Hi there, I am wondering if it is possible to navigate anchor links using a button onclick event. I want next and previous hit buttons to navigate the already existing hits (#hit1, #hit2, etc.). For instance, I have: Code: <script type="text/javascript"> var numHits = {HITS}-1; function nextHit(){ if(numHits > 0){ numHits--; } return("location.href=" '#hit" + numHits + " ' ");//added spaces for visibility } </script> <input type="button" value=">" onclick="nextHit()" /> I have tried onclick="nextHit();", onclick="nextHit(); return true/false", onclick=" return nextHit()" and a bunch of others, with no luck. I have seen working examples with the href tag (e.g. <a href="#" onclick="func();return false">), but nothing with buttons. I also can't seem to get the working href examples to work on my server. For instance, I cannot get this code to work, it just goes to js_required.html: <a href="js_required.html" onclick="doSomething(); return false;">go</a> function doSomething(){ alert("test"); } It seems so simple, I'm assuming I'm missing something very basic. I would greatly appreciate any help! ~Bobio |