JavaScript - Using Ajax On Pagination Aswell As Dropdown
On my website, I have a drop down selection for County which goes off and gets all pubs in that county using Ajax, which works fine:
http://www.mypubspace.com What I would like to do is to pass through the PAGE (from the querystring too) here is my function on the drop down Code: <script> function countyFunction(){ var countyRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari countyRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ countyRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ countyRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server countyRequest.onreadystatechange = function(){ if(countyRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = countyRequest.responseText; } } var name = document.getElementById('name').value; var rsCounty = document.getElementById('rsCounty').value; var page = document.getElementById('page').value; var queryString = "?name=" + name + "&rsCounty=" + rsCounty + "&page=" + page; //Add the following line countyRequest.open("GET", "http://www.mypubspace.com/countypubs.php" + queryString, true); countyRequest.send(null); } </script> <select name="menu2" onChange="countyFunction();" class="textbox" id="rsCounty"> <option value="">Search by County...</option> <? $county_pubs = mysql_query("SELECT DISTINCT RSCOUNTY, COUNT(PUBID) As PubCount1 FROM pubs GROUP BY RSCOUNTY ORDER BY RSCOUNTY ASC") ?> <?php while($row1 = mysql_fetch_array($county_pubs)) { echo '<option value="'.$row1['RSCOUNTY'].'">'.$row1['RSCOUNTY'].' ('.$row1['PubCount1'].')</option>'; } ?> </select> <input type='hidden' id='name' /> <input type='hidden' id='rsCounty' /> <input type='hidden' id='rsTown' /> <input type='hidden' id='page' /> and on the following page is my data and pagination: Code: <?php if ($msg <>"") { echo "<div class=\"ui-widget\"> <div style=\"padding: 0pt 0.7em;\" class=\"ui-state-error ui-corner-all\"> <p style=\"padding-top:18px;\"><span style=\"float: left; margin-right: 0.3em;\" class=\"ui-icon ui-icon-alert\"></span> <strong>Alert:</strong> $msg</p> </div> </div>"; } $tableName="pubs"; $targetpage = "county_pubs.php"; $limit = 20; $query = "SELECT COUNT(*) as num FROM $tableName WHERE RSCOUNTY = '".$County."'"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages['num']; $stages = 3; $page = mysql_escape_string($_REQUEST['page']); if( isset($_REQUEST['page']) && ctype_digit($_REQUEST['page']) ) { $page = (int) $_GET['page']; $start = ($page - 1) * $limit; }else{ $start = 0; } // Get page data $query1 = "SELECT * FROM $tableName WHERE RSCOUNTY = '".$County."' ORDER BY rsPubName asc LIMIT $start, $limit"; $result = mysql_query($query1); // Initial page num setup if ($page == 0){$page = 1;} $prev = $page - 1; $next = $page + 1; $lastpage = ceil($total_pages/$limit); $LastPagem1 = $lastpage - 1; $paginate = ''; if($lastpage > 1) { $paginate .= "<span class='paginate'>"; // Previous if ($page > 1){ $paginate.= "<a href='$targetpage?page=$prev&rsCounty=$County'>previous</a>"; }else{ $paginate.= "<span class='disabled'>previous</span>"; } // Pages if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter&rsCounty=$County'>$counter</a>";} } } elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few? { // Beginning only hide later pages if($page < 1 + ($stages * 2)) { for ($counter = 1; $counter < 4 + ($stages * 2); $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter&rsCounty=$County'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1&rsCounty=$County'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage&rsCounty=$County'>$lastpage</a>"; } // Middle hide some front and some back elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2)) { $paginate.= "<a href='$targetpage?page=1&rsCounty=$County'>1</a>"; $paginate.= "<a href='$targetpage?page=2&rsCounty=$County'>2</a>"; $paginate.= "..."; for ($counter = $page - $stages; $counter <= $page + $stages; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter&rsCounty=$County'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1&rsCounty=$County'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage&rsCounty=$County'>$lastpage</a>"; } // End only hide early pages else { $paginate.= "<a id='page' href='$targetpage?page=1&rsCounty=$County'>1</a>"; $paginate.= "<a id='page' href='$targetpage?page=2&rsCounty=$County'>2</a>"; $paginate.= "..."; for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a id='page' href='$targetpage?page=$counter&rsCounty=$County'>$counter</a>";} } } } // Next if ($page < $counter - 1){ $paginate.= "<a id='page' href='$targetpage?page=$next&rsCounty=$County'>next</a>"; }else{ $paginate.= "<span class='disabled'>next</span>"; } $paginate.= "</span>"; } echo 'Pubs found: '.$total_pages; // pagination echo $paginate; ?> <div id="accordion"> <?php while($row = mysql_fetch_array($result)) { echo '<div><h3><a href="#">'.$row['rsPubName'].', '.$row['rsTown'].'</a></h3><div>'.$row['rsAddress'].'<br />'.$row['rsTown'].', '.$row['rsCounty'].'<br />'.$row['rsPostCode'].'<br /><br />Region: '.$row['Region'].'<br /><br />Telephone: '.$row['rsTel'].'<br /><br />'; echo '<button onclick="gohere(\'viewpub.php?PUBID='.$row['PUBID'].'\')" type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">View Pub</span></button>'; echo '</div></div>'; } echo '<span style="float:right;">'.$paginate.'</span>'; ?> Similar TutorialsHi Chaps, I'm trying to get a AJAX script to work, but am having problems. I have a page with two dropdown menus, the idea is that the first dropdown [customers] will then filter the options of the second [contacts]: //DROPDOWN.PHP PHP Code: <form method="post" action=""> <select name="customer" onChange="ContactGrab('."'".'ajaxcalling.php?id='."'".'+this.value);"> <option value="">Select Customer</option> <?php do { ?> <?php echo "<option value=".'"'.$row_rsCustomer['custid'].'" >'.$row_rsCustomer['custname']."</option>";?> <?php } while ($row_rsCustomer = mysql_fetch_assoc($rsCustomer)); $rows = mysql_num_rows($rsCustomer); if($rows > 0) { mysql_data_seek($rsCustomer, 0); $row_rsCustomer = mysql_fetch_assoc($rsCustomer); } ?> </select><br /> <div id="details"> <select name="details"> <option value="">Select Contact</option> <?php do { ?> <option value="<?php echo $row_rsContact['contactname']?>"><?php echo $row_rsContact['contactname']?></option> <?php } while ($row_rsContact = mysql_fetch_assoc($rsContact)); $rows = mysql_num_rows($rsContact); if($rows > 0) { mysql_data_seek($rsContact, 0); $row_rsContact = mysql_fetch_assoc($rsContact); } ?> </select> </div> </form> The OnChange action should call the AJAXCALLING.PHP page, where the other select options are filtered, by column [FK_custid] //AJAXCALLING.PHP PHP Code: <select name="details"> <option value="">Select Contact</option> <?php do { ?> <option value="<?php echo $row_rsContact['contactid']?>"><?php echo $row_rsContact['contactname']?></option> <?php } while ($row_rsContact = mysql_fetch_assoc($rsContact)); $rows = mysql_num_rows($rsContact); if($rows > 0) { mysql_data_seek($rsContact, 0); $row_rsContact = mysql_fetch_assoc($rsContact); } ?> </select> This is powered by the AJAXSCRIPT.JS page Code: function CreateXmlHttpObject() { //fuction to return the xml http object var xmlhttp=false; try{ xmlhttp=new XMLHttpRequest();//creates a new ajax object } catch(e) { try{ xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");//this is for IE browser } catch(e){ try{ req = new ActiveXObject("Msxml2.XMLHTTP");//this is for IE browser } catch(e1){ xmlhttp=false;//error creating object } } } return xmlhttp; } function CategoryGrab(strURL) { var req = CreateXmlHttpObject(); // fuction to get xmlhttp object if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { //data is retrieved from server if (req.status == 200) { // which reprents ok status document.getElementById('details').innerHTML=req.responseText;//put the results of the requests in or element } else { alert("There was a problem while using XMLHTTP:\n"); } } } req.open("GET", strURL, true); //open url using get method req.send(null);//send the results } } My problem is that when I open the dropdown.php page, the browser status says 'Done, but with errors on the page' and the second dropdown isn't filtering. I can get rid of the status warning by removing: Quote: ...onChange="ContactGrab('."'".'ajaxcalling.php?id='."'".'+this.value);"> But obviously that is something that is needed to pass the [custid] in the URL parameter.... Can anyone help me on this, as I haven't got a clue what I'm missing or where I have gone wrong! Hi All, i have a javascript function which i pass 3 fields to which then check to see if they are empty but the two other fields txtDeveloperDetailEstimate and TxtAldonTaskNumber are numeric and i need to check for != NaN but when i fill something in to the comment area it comes back as red even though there is some text in it, how can i check for the numeric values of the other two without interupting the first check for comments etc? Code: var DevFieldCheck = Array('MainDisplayContentChange_txtDeveloperComment', 'MainDisplayContentChange_txtDeveloperDetailEstimate', 'MainDisplayContentChange_txtAldonTaskNumber'); var obj; function DevItemCheck(windowname) { for (var i = 0; i < DevFieldCheck.length; i++) { obj = document.getElementById(DevFieldCheck[i]); if (obj.value == "" || obj.value == 0 || obj.value != NaN) { obj.style.backgroundColor = "#B20635"; return false; } } Businesspopup(windowname) } Any help will be highly appreciated. **Update** Iv tried this aswell but it still turns red when there is a number in there Code: var DevFieldCheck = Array('MainDisplayContentChange_txtDeveloperComment'); var obj; function DevItemCheck(windowname) { for (var i = 0; i < DevFieldCheck.length; i++) { obj = document.getElementById(DevFieldCheck[i]); if (obj.value == "" || obj.value == 0) { obj.style.backgroundColor = "#B20635"; return false; } } if (document.getElementById('MainDisplayContentChange_txtDeveloperDetailEstimate').value = NaN) { document.getElementById('MainDisplayContentChange_txtDeveloperDetailEstimate').style.backgroundColor = "#B20635"; return false; } if (document.getElementById('MainDisplayContentChange_txtAldonTaskNumber').value == NaN) { document.getElementById('MainDisplayContentChange_txtAldonTaskNumber').style.backgroundColor = "#B20635"; return false; } AnotherDevpopup(windowname) } Im aware i have one line with "=" and the other with "==" i was testing both out...to see if it made a difference Hi, I'm trying to integrate an address finder (http://www.craftyclicks.co.uk/) into my shopping cart (OsCommerce). I can get it to work but I need to add my own functionality. I'm not very experienced with JavaScript and my head has entered an infinite loop by now. The problem is that the address finder script can change the selected country in a drop-down list depending on the postcode entered by the user (using the onblur event handler). What I need it to do is to remove all other countries depending on the postcode. I can get it to remove all other countries but how do i return to the original list of countries when the postcode is changed again? Once all other counties are removed, the drop-down list will obviously only have one option left... I guess the question is also how does a function remember what it has done before, when it is called again? I have written this short test script as it is easier to work with than the craftyclicks oscommerce contribution: 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>HTML Template</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="description" content="" /> <meta name="keywords" content="" /> <script type="text/javascript"> //<![CDATA[ function store(element) { // store values var cl = element; var text_list = new Array(); var value_list = new Array(); var length = cl.length; for (var foo=0; foo<length; foo++) { text_list[foo] = cl.options[foo].text; value_list[foo] = cl.options[foo].value; alert("text array " + foo + " " + text_list[foo]); alert("value array " + foo + " " + value_list[foo]); } populate(cl, text_list, value_list); } function populate(element, text, value) { // populate options with previously stored values var cl = element; var length = cl.length; cl.options.length=0; for (var bar=0; bar<length; bar++) { cl.options[bar]= new Option(text[bar], value[bar], false, false); } } function crafty_set_country(code) { var cl = document.getElementById('select'); store(cl); for (var i=0; i<cl.length; i++) { if (cl.options[i].value == code) { alert(cl.options[i].value + " found"); var value = cl.options[i].value; var text = cl.options[i].text; cl.options.length=0; cl.options[0]=new Option(text, value, true, true); /* for (var j=0; j<cl.length; j++) { alert("second loop " + cl.options[j].text); if (cl.options[i].value != code) { cl.options[j] } } */ } else { alert(cl.options[i].value); } } } //]]> </script> </head> <body> <form> <select id="select"> <option value="10">ten</option> <option value="20">twenty</option> <option value="30">thirty</option> <option value="40">fourty</option> <option value="50">fifty</option> <option value="60">sixty</option> </select> <input type="button" value="remove" name="button" onClick="crafty_set_country(50)"> <input type="button" value="repopulate" name="button" onClick="crafty_set_country(100)"> </form> </body> </html> Many thanks! Martin hey guys The first dropdown has some options as : abc(a) bcd(a) cde(b) def(b) efg(c) fgh(c) The second dropdown has : a b c On selecting abc(a) in first dropdown the 'a' must get selected in second dropdown,on selecting cde(b) second dropdown must have 'b' and so on,also the second dropdown value should be disabled(grayed out) for user.Need the code in javascript.ty in advance. Hi, I am hoping I just need to be pointed in the right direction with this. I have Page1. When Page1 body onloads it uses Ajax to call PartA Within PartA I have a message board so members can write messages which will be sent to my database in PartA[1] and immediately posted for view on to PartA[2]. As I want to have my request to the server updating regularly I want to have PartA[2] on a timed loop to refresh - I do not need the content of PartA[1] to refresh. So the order of events would look like this: Page1 | onload call | v PartA / \ V V PartA[1] PartA[2] (loads once) (constantly refreshes) What I am not sure about is that I have <body> and <head> attributes in Page1 only. I have already used my body onload to call PartA (and can't use it to call PartA[2] before PartA has loaded anyway). I do not want the user to have to click a button or do anything to call up PartA[2]. So my question is how would I get PartA[2] to automatically load within PartA? I hope I have made this clear, but if I haven't let me know and I will try again. Hello, I am completely new to HTML/JS/CSS, therefore I know very little. I have two drop-down prompt controls with month names. One has just one value (say "July") and the other has all the months of the year ("January".."December"). The first prompt control is hidden on the page. How do I set the default selection of the second prompt control to the value present in the first prompt control? So, when the page is run, the second prompt control should automatically show "July". I was reading up on the selectedIndex property (?), but I know that it won't work because I want Index 0 to be selected in the first control and Index 6 in the second, and I expect it to change every month (next month it will be index 7 that should be automatically selected). If it matters, I am using IE8. Thanks! Hi, I have two dropdown lists with the second one being dependent on the selection in the first. Options in list 1: 1,3 or 4 List two should be enabled when 3 or 4 is selected in list 1. So far so good, managed to get it to work with only one set of lists, but I actually have 18 of those sets in this form: Code: <select name="fw[$i]" id="fw[$i]"> <option value="1">FWH</option> <option value="3">links</option> <option value="4">rechts</option> <option value="0" selected></option> </select><br /> <select name="lie[$i]" id="lie[$i]" disabled="disabled" onchange="showBox($i,xxx);"> <option value="0" selected>---</option> <option value="1">gut</option> <option value="2">schlecht</option> <option value="3">Strafschlag</option> <option value="4">OB</option> </select> $i is my index generated by my PHP script and runs from 1 to 18. Everything works just fine as long as the index is not in play. With the index my function breaks, most probably due to my inability to extract the second parameter (xxx above) from the selection field. Here's my function, there could be something wrong there too with how exactly to specify the proper dropdown list to enable. Code: function showBox(field,val) { if (val > 1) { var box = 'lie[' + field + ']'; document.form1.box.disabled == false; } else { document.form1.box.disabled == true; } } Finally, I'm not that adept in javascript programming, more like a trial and error guy, how has hit the wall with this problem. Thanks in advance! Joe I need help with pagination setup for my javascript image display. The images I have now display when I select a certain category dynamically but I don't know how to implement javascript pagination into this code. I also don't know how to call it in my display page so that the images appear in a box and has separation in between them cause right now the images all display but connected to one another. I am new to javascript and the coding world so I really hope someone can help me out cause I've been trying to figure out how for the past 2 weeks now. Right now I have the code: Code: <div id="ImageContainer"></div> <br /> <script type="text/javascript"><!-- function ShowGallery() { // get parent for image container and remove image container var parentcontainer = document.getElementById("ImageContainer").parentNode; parentcontainer.removeChild(document.getElementById("ImageContainer")); // get current image gallery information from dropdown var dropdown = document.getElementById("catDropDown"); var selectedoption = dropdown.getElementsByTagName("option")[dropdown.selectedIndex]; var count = parseInt(selectedoption.getAttribute("Count")); // if there are not images in the category, return - "select a category" falls into this case as well if(count<=0) return; // populate images in image elements var container = document.createElement("div"); container.setAttribute("id","ImageContainer"); for(var i=0;i<count;i++) { var img=document.createElement("img"); img.setAttribute("src","images/th/thumb_"+dropdown.value+(i<9?"0":"")+(i+1)+".jpg"); img.setAttribute("alt","images/th/thumb_"+dropdown.value+(i<9?"0":"")+(i+1)+".jpg"); container.appendChild(img); } // Insert new image container back with new contents parentcontainer.appendChild(container); } Hi. does anyone know how websites like www.fmylife.com or mylifeisaverage.com do their pagination? Do they just store all the posts in a database and then call them out? I'm asking this because I am wondering how I should paginate. Thanks
Hi, I have a table with a list of items which currently show 8 items per page. I want to have an input box at the top of the page so if I want a different amount of items to be shown i enter the number and the page alters the pagination to what ever number is entered. Hope this makes sense. Thanks for any help Hi, I have been playing with Slidersjs and have it sliding through my images just fine, however the previous/next and slide identifiers below the images don't seem to work and I can't see how to make them active. The temp link is he http://mono-zine.com/Mono.LogDM.html and the slide is the second one down. The identifiers should be clickable to take you to a specific slide, whilst they do change they dont click. Any help gratefully received. The script is from he http://slidesjs.com/ Cheers so.. im tryign to paginate a div with content being added by an input. but its not working at all... first, I got this input: Code: <form name="postbar_add_post" id="postbar_add_post" method="post"> <fieldset> <legend>What chu doign? ...</legend> <input type="text" name="addcontentbox" id="addcontentbox" maxlength="200" /> <input type="submit" name="addpost" value="Submit" class="submit" /> </fieldset> </form> then, what i will happen is that, the content being submited, will be posted to an unsorted list, named wall, i used jquery to help me out on this, heres the script: Code: <script type="text/javascript"> $(document).ready(function(){ $("form#postbar_add_post").submit(function() { var addcontentbox = $('#addcontentbox').attr('value'); if ( addcontentbox.replace(/\s/g,"") == "" ) return false; $.ajax({ type: "POST", url: "postear.php", data:"addcontentbox="+ addcontentbox, success: function(){ $("ul#wall").prepend("<li>"+addcontentbox+"</li>"); $("ul#wall li:first").fadeIn(); document.postbar_add_post.addcontentbox.value=''; document.postbar_add_post.addcontentbox.focus(); } }); return false; }); }); </script> the div where it is beign opsted at, looks like this: Code: <div id="cuerpo"><ul id="wall"></ul></div> adn then, below i got this div, wich is where the navgiation links will be at: (before u read, "current_page" and "show_per_page" are 2 hidden inputes to save the values.) Code: <div id="navwrapper"></div> so, to make the navigation, i found a script online and tried to adapt it to the div, i got this: Code: $(document).ready(function(){ //how much items per page to show var show_per_page = 5; //getting the amount of elements inside content div . var number_of_items = $('#wall').children().size(); //calculate the number of pages we are going to have var number_of_pages = Math.ceil(number_of_items/show_per_page); //set the value of our hidden input fields $('#current_page').val(0); $('#show_per_page').val(show_per_page); //navigation ' var navigation_html = '<a class="previous_link" href="javascript:previous();">Prev</a>'; var current_link = 0; while(number_of_pages > current_link){ navigation_html += '<a class="page_link" href="javascript:go_to_page(' + current_link +')" longdesc="' + current_link +'">'+ (current_link + 1) +'</a>'; current_link++; } navigation_html += '<a class="next_link" href="javascript:next();">Next</a>'; $('#navwrapper').html(navigation_html); //add active_page class to the first page link $('#navwrapper .page_link:first').addClass('active_page'); //hide all the elements inside content div $('#wall').children().css('display', 'none'); //and show the first n (show_per_page) elements $('#wall').children().slice(0, show_per_page).css('display', 'block'); }); function previous(){ new_page = parseInt($('#current_page').val()) - 1; //if there is an item before the current active link run the function if($('.active_page').prev('.page_link').length==true){ go_to_page(new_page); } } function next(){ new_page = parseInt($('#current_page').val()) + 1; //if there is an item after the current active link run the function if($('.active_page').next('.page_link').length==true){ go_to_page(new_page); } } function go_to_page(page_num){ //get the number of items shown per page var show_per_page = parseInt($('#show_per_page').val()); //get the element number where to start the slice from start_from = page_num * show_per_page; //get the element number where to end the slice end_on = start_from + show_per_page; //hide all children elements of content div, get specific items and show them $('#wall').children().css('display', 'none').slice(start_from, end_on).css('display', 'block'); /*get the page link that has longdesc attribute of the current page and add active_page class to it and remove that class from previously active page link*/ $('.page_link[longdesc=' + page_num +']').addClass('active_page').siblings('.active_page').removeClass('active_page'); //update the current page input field $('#current_page').val(page_num); } but all looks cool but... it is actually not working... everything its being posted great to the unsorted listt, but its not paging =S. .. it just all shows on the div, and scrolls. Could it be somethign on the css? ... or... what ...? =| Guidance? =( . my brains toasted. =\ I'm having a slight problem with php pagination and jquery/js. On the following page http://dev2.bluemuledesign.com/athletes.php you'll see an "athlete profile" area. Whenever an athlete photo is selected, javascript/php are used to switch out the athlete info. This works perfectly fine. The problem occurs if I use the left or right arrows to view more athletes (the left and right arrows are set with php pagination to switch to the next four records in the database). Whenever I do this, the athlete info defaults back to the first person from the initial load. Also, the javascript/jquery quits working and won't let me view the info for one of the newly displayed athletes. So I have two questions: 1) Can anyone tell me why it defaults back to the original athlete info? I'm assuming it has something to do with me not setting a cookie to remember the currently selected athlete. 2) Why does the javascript quit working when I view the next set of athletes? Also, the jquery slideshow that I am implementing is an alteration of this: http://designm.ag/tutorials/image-rotator-css-jquery/ Any help would be greatly appreciated. I'm trying to create a type of virtual pagination that's simple, semantic, and SEO friendly. The concept is like this website: www.doner.com In the bottom right hand corner, if you select a city, different contact information appears. My theory is to assign a class name to the hyperlink, then have a DIV with a matching ID. For example... Code: <a href="#" class="michigan">Michigan</a> <a href="#" class="ohio">Ohio</a> <a href="#" class="illinois">Illinois</a> <div id="michigan"> Michigan container </div> <div id="ohio"> Ohio container </div> <div id="illinois"> Illinois container </div> The JavaScript I have written so far is... Code: var anchor = document.getElementsByTagName('a').className; // grab all hyperlinks and their classes var div = document.getElementsByTagName('div').getElementByID; // grab all divs and their IDs if (anchor = div) { // check to see if a hyperlink's class has a matching div ID div.style.display = "none"; if (anchor.onclick) { // if the hyperlink is clicked... div.style.display = "visible"; // make matching div ID visible } } Nothing works yet, and I don't know where to continue. The DIVs aren't even hidden upon loading. Can anyone help me? i have a html wich i am working on .. Code: <html> <head> <script language="Javascript"> function xmlhttpPost(strURL) { var xmlHttpReq = false; var self = this; // Mozilla/Safari if (window.XMLHttpRequest) { self.xmlHttpReq = new XMLHttpRequest(); } // IE else if (window.ActiveXObject) { self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } self.xmlHttpReq.open('POST', strURL, true); self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); self.xmlHttpReq.onreadystatechange = function() { if (self.xmlHttpReq.readyState == 4) { updatepage(self.xmlHttpReq.responseText); } } self.xmlHttpReq.send(getquerystring()); } function getquerystring() { var form = document.forms['f1']; var username = form.username.value; qstr = 'u=' + escape(username); return qstr; } function updatepage(str){ var s = str; var a = s.split(','); var a1 = a[0]; var a1_1 = a[1]; var a2 = a[2]; var a2_1 = a[3]; var a3 = a[4]; var a3_1 = a[5]; var a4 = a[6]; var a4_1 = a[7]; var a5 = a[8]; var a5_1 = a[9]; var a6 = a[10]; var a6_1 = a[11]; var a7 = a[12]; var a7_1 = a[13]; var a8 = a[14]; var a8_1 = a[15]; var a9 = a[16]; var a9_1 = a[17]; var a0 = a[18]; var a0_1 = a[19]; var form = document.forms['f1']; form.result1.value = a1; form.result1_1.value = a1_1; form.result2.value = a2; form.result2_1.value = a2_1; form.result3.value = a3; form.result3_1.value = a3_1; form.result4.value = a4; form.result4_1.value = a4_1; form.result5.value = a5; form.result5_1.value = a5_1; form.result6.value = a6; form.result6_1.value = a6_1; form.result7.value = a7; form.result7_1.value = a7_1; form.result8.value = a8; form.result8_1.value = a8_1; form.result9.value = a9; form.result9_1.value = a9_1; form.result0.value = a0; form.result0_1.value = a0_1; } </script> </head> <body> <form name="f1"> <p>Username: <input name="username" type="text" id="username"> <p>Password: <input name="password" type="text" id="password"> <input value="Go" type="button" onclick='JavaScript:xmlhttpPost("/cgi-bin/3sms/smscontacts.pl")'></p> <input name="result1" type="text" id="result1" size="18" maxlength="25"> <input name="result1_1" type="text" id="result1_1" size="11" maxlength="11"><p> <input name="result2" type="text" id="result2" size="18" maxlength="25"> <input name="result2_1" type="text" id="result2_1" size="11" maxlength="11"><p> <input name="result3" type="text" id="result3" size="18" maxlength="25"> <input name="result3_1" type="text" id="result3_1" size="11" maxlength="11"><p> <input name="result4" type="text" id="result4" size="18" maxlength="25"> <input name="result4_1" type="text" id="result4_1" size="11" maxlength="11"><p> <input name="result5" type="text" id="result5" size="18" maxlength="25"> <input name="result5_1" type="text" id="result5_1" size="11" maxlength="11"><p> <input name="result6" type="text" id="result6" size="18" maxlength="25"> <input name="result6_1" type="text" id="result6_1" size="11" maxlength="11"><p> <input name="result7" type="text" id="result7" size="18" maxlength="25"> <input name="result7_1" type="text" id="result7_1" size="11" maxlength="11"><p> <input name="result8" type="text" id="result8" size="18" maxlength="25"> <input name="result8_1" type="text" id="result8_1" size="11" maxlength="11"><p> <input name="result9" type="text" id="result9" size="18" maxlength="25"> <input name="result9_1" type="text" id="result9_1" size="11" maxlength="11"><p> <input name="result0" type="text" id="result0" size="18" maxlength="25"> <input name="result0_1" type="text" id="result0_1" size="11" maxlength="11"><p> </div> </form> </body> </html> now my problem is the password is not sent to the perl script i basicly modified an ajax from another form to do this form. when the "go" is pressed the username is sent and a string is recived and devided into the form inputs.. all i need to do now is send the password along with the username the username variable is "u" i would like the password variable to be "p" any ideas hi; This is my first post and am abit stuck. I used JQuery AJAX to get data from a different page and show it in my div. This all works fine but now i want the page collected by AJAX to execute a Javascript function which is in the page which request the AJAX page. I have this so far but its not working. This is in the AJAX-ed page. Code: <a href="#" onClick="change_postcode(prompt('Please Enter Your Postcode', 'SW10')"); )">SW10</a> And the page which requested the AJAX page. Code: <script type="text/javascript"> function change_postcode(postcode){ $('#view8').html('<p><img src="http://www.MySite.com/images/loading.gif"/><br />Loading! Please Wait...</p>'); $('#view8').load("http://www.mywebsite.com/include.php?inc=Events&when=&postcode="+postcode); }</script> I though about using top but that didn't work. Code: <a href="#" onClick="top.change_postcode(prompt('Please Enter Your Postcode', 'SW10')"); )">SW10</a> How can i get my AJAX page to execute a Javascript function which is in the page which contains the the AJAX page. Thankyou all for reading my post Paul P.S Am very sorry for my way with words. Hello everyone. I was working on a ajax function and I can't seem to figure out what I'm doing wrong here. I'm kinda new with the prototype method I was wondering if I could get some help figuring out what I'm doing wrong here exactly and how I can fix this. Any help on this would be wonderful. Thanks, Jon W Code: function createAjax() { if(!this.http && window.ActiveXObject) { try { this.http = new ActiveXObject("Msxml2.XMLHTTP" || "Microsoft.XMLHTTP"); } catch(e1) { this.http = false; } } if(!this.http && window.XMLHttpRequest) { try { this.http = new XMLHttpRequest(); } catch(e2) { alert("Sorry we was unable to make a request between your browser."); } } } createAjax.prototype.request = function(url) { var rmd = Math.random(); this.http.open('get', url+"&rmd="+rmd, true); this.http.send(null); this.http.onreadystatechange = this.responseHandler; } createAjax.prototype.responseHandler = function(obj) { if(this.http.readyState == 4) { document.getElementById(obj).innerHTML = this.responseText; } } function ajax(url, obj) { a = new createAjax(); a.request(url); a.responseHandler(obj); } var doAjax = new ajax('ajax.php?name=jon','content'); I need some help with some javascript I am trying to put on an IF forum. http://s7.invisionfree.com/AJAXTEST/index.php At the very top, you will see a link called "on this link". It is an ajax code. If you click on it, a blank alert box comes up. However, if you go he http://commx.info/will/test.html and click on the same link, the alert box has the text I am looking for. It uses the exact same code, so I can't figure out why it works on a plain page and not on an IF forum. Does anyone have any ideas? The code is Code: <html><head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><script> function callback(serverData, serverStatus) { alert(serverData); } function ajaxRequest() { var AJAX = null; if (window.XMLHttpRequest) { AJAX=new XMLHttpRequest(); } else { AJAX=new ActiveXObject("Microsoft.XMLHTTP"); } if (AJAX==null) { alert("Your browser doesn't support AJAX."); return false } AJAX.onreadystatechange = function() { if (AJAX.readyState==4 || AJAX.readyState=="complete") { callback(AJAX.responseText, AJAX.status); } } AJAX.open("GET",'http://commx.info/accounts/codes/shout/ipb13/getChatData.php?lastID=0', true); AJAX.send(null); } </script> </head><body><a href="javascript:ajaxRequest()">on this link</a></body></html> I was wondering if someone would have the time to talk and help explain some Ajax things to me... slowly. I'm trying to make my web sites more dynamic. Like I just need someone I can bounce ideas off and they can walk me through step by step on how to do them. Thanks Shelby |