JavaScript - Parse Post Results Token
I'm making a javascript POST that returns some information in this format. It's copied from the web API website I'm developing from.
Returns a token on success. Code: { "errors": [ ], "warnings": [ ], "data": { "token": "ta98585435afabcf26319e2038a09f40" }, "page": { "current": 1, "total": 1 } } How can I get the data.token bit out specifically? Similar TutorialsAll, If I have the following code: Code: var http_request = false; function makePOSTRequest(url, parameters, str) { http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { // set type accordingly to anticipated content type //http_request.overrideMimeType('text/xml'); http_request.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Cannot create XMLHTTP instance'); return false; } http_request.onreadystatechange = alertContents; http_request.open('POST', url, true); http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http_request.setRequestHeader("Content-length", parameters.length); http_request.setRequestHeader("Connection", "close"); http_request.send(parameters); } function alertContents() { if (http_request.readyState == 4) { if (http_request.status == 200) { //alert(http_request.responseText); result = http_request.responseText; document.getElementById('myspan').innerHTML = result; window.location.hash = "#picture_id"; resizeAll(); } else { alert('There was a problem with the request.'); } } } function getpic(obj) { var poststr = "picture=" + encodeURI( document.getElementById("picture").value ); makePOSTRequest('getnextpic.php', poststr); } How can I parse: Code: result = http_request.responseText; So I can get a picture_id so I can update my hash on this line? Code: window.location.hash = "#picture_id"; Thanks in advance. Hello, I need some help.. I'm using this example script and need the search results to post to a another frame and not a new window. Code: searchh.js // Multi Search - Head Script // copyright Stephen Chapman, 4th August 2005 // you may copy this clock provided that you retain the copyright notice function start() { var i = Math.floor(Math.random() * document.searchbox.engine.length); document.searchbox.engine[i].selected = true; } window.onload = start; function search() { searchTerm = document.searchbox.term.value; var searchVal = ''; if(searchTerm != '') { searchTerm = searchTerm.replace(/\s/ig, '+'); searchEngine = document.searchbox.engine[document.searchbox.engine.selectedIndex].value; switch (searchEngine) { case 'about': searchVal = 'http:\/\/search.about.com\/fullsearch.htm?terms=' + searchTerm; break; ... default: break;} if (searchVal != '') window.open(searchVal,'search'); }} Code: searchb.js //copyright Stephen Chapman, 4th August 2005 // you may copy this script provided that you retain the copyright notice document.write('<div align="center"><form name="searchbox" action="">\nSearch for: <input name="term" type="text" size="15" maxlength="80" \/> With:\n<select name="engine">\n<option value="about">About<\/option>\n<option value="accoona">Accoona<\/option>\n<option value="alltheweb">AllTheWeb<\/option>\n<option ... value="yahoo">Yahoo<\/option>\n<\/select>\n<input type="button" value="Go!" onclick="search()" \/>\n<\/form><\/div>'); Sorry but i'm just newbie , just need a little hint on what to do. Need the results to showup in frame "test1" Or if someone can direct me: looking for a multi search drop down list in a frame environment where after submitting the string the results would show in another frame Thanks Hello, I do not have a lot of experience with Java and my HTML skills have not been put to use in a few years. The problem that I am having is trying to call a .js from an IIS footer file. The script is Code: <!-- Piwik --> <script type="text/javascript"> var pkBaseURL = (("https:" == document.location.protocol) ? "https://216.128.27.18/" : "http://216.128.27.18/"); document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E")); </script><script type="text/javascript"> try { var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 25); piwikTracker.trackPageView(); piwikTracker.enableLinkTracking(); } catch( err ) {} </script><noscript><p><img src="http://216.128.27.18/piwik.php?idsite=25" style="border:0" alt="" /></p></noscript> <!-- End Piwik Tracking Code --> When added directly to the <body></body> of the html it works but i want to append it to all pages with a footer. I created an piwik.js with that above code then made an html file with Code: <script src="piwikfooter.js" type="text/javascript"></script> It does try to call the script but I get an error when loading the site piwikfooter.js:2Uncaught SyntaxError: Unexpected token< Any help would be very much appreciated. Hi i have set up a token key to give me some extra protection against direct url access to the page but i wanted to make it random. at first i used session token but it is not set until after a page refresh on login so this has to be its own deal.. i have found several javascript random codes but how to i pass that value to the window call.. here is the window call.. as you can see right know i have it hard coded as one token all the time. i just need it random and then sha1 (or md5) Code: function url_chat(){ chatwindow = window.open("<?=$CONST_MY_ROOT?>/mychat/chat/index.php?tok=0ed61bdd3a8a86f39e6b4abd01ba4e3649d0ec1c", "chatwindow", "location=0,status=0,scrollbars=0,menubar=0,resizable=0,width=950,height=550"); } i could use this i guess but i dont know how to get that value to the window call above. Code: document.write(Math.floor(Math.random()*999999999999999999)); Hello i'm using TinyceEditor in my website and i'm using AjaxFileManager to upload images. It works very good in my localhost, but in the remote server while uploading image an error appears (" Syntaxerror: unexpected token < ") and uploading stop. please i need the answer quickly public classTestGeometricObject{ /** Main Method */ public static void main(String[] args) { //Declare and initialize two geometric objects GeometricObject geoObject1 = new Circle(5); GeometricObject geoObject2 = new Rectangles(5,3); System.out.println("The two objects have the same area? " + equalArea(geoObject1, geoObject2)); //Display circle displayGeometricObject(geoObject1); //Display rectangle displayGeometricObject(geoObject2); } /**A method for comparing */ public static boolean equalArea(GeometricObject object1, GeometricObject object2) { return object1.getArea()==object2.getArea(); } /**A method for displaying a geometric object*/ public static void displayGeometricObject(GeometricObject object){ System.out.println(); System.out.println("The area is " + object.getArea()); System.out.println("The perimeter is " + object.geetPerimeter()); } } public classTestGeometricObject{ /** Main Method */ public static void main(String[] args) { //Declare and initialize two geometric objects GeometricObject geoObject1 = new Circle(5); GeometricObject geoObject2 = new Rectangles(5,3); System.out.println("The two objects have the same area? " + equalArea(geoObject1, geoObject2)); //Display circle displayGeometricObject(geoObject1); //Display rectangle displayGeometricObject(geoObject2); } /**A method for comparing */ public static boolean equalArea(GeometricObject object1, GeometricObject object2) { return object1.getArea()==object2.getArea(); } /**A method for displaying a geometric object*/ public static void displayGeometricObject(GeometricObject object){ System.out.println(); System.out.println("The area is " + object.getArea()); System.out.println("The perimeter is " + object.getPerimeter()); } } view the rest of my comments works on the first page but when i extend the search results the rest of the view comments wont expand. click View all 3 comments and it will show all comments then click more button try to click the view all comments on the next comment and nothing happens but the screen jumping up to the top. http://www.runningprofiles.com/membe...ll_Script.php# Why is this?? What do i need to do to fix it? PHP 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> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>9lessons Applicatio Demo</title> <link href="frame.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script> <script type="text/javascript" src="jquery.oembed.js"></script> <script type="text/javascript"> $(function() { $('.more').live("click",function() { var ID = $(this).attr("id"); if(ID) { $("#more"+ID).html('<img src="moreajax.gif" />'); $.ajax({ type: "POST", url: "http://www.runningprofiles.com/members/shout/data/ajax_more.php", data: "lastmsg="+ ID, cache: false, success: function(html){ $("ol#updates").append(html); $("#more"+ID).remove(); // removing old more button } }); } else { $(".morebox").html('The End');// no results } return false; }); }); $(function() { $(".view_comments").click(function() { var ID = $(this).attr("id"); $.ajax({ type: "POST", url: "../viewajax.php", data: "msg_id="+ ID, cache: false, success: function(html){ $("#view_comments"+ID).prepend(html); $("#view"+ID).remove(); $("#two_comments"+ID).remove(); } }); return false; }); }); $(function() { $(".comment_button").click(function() { var element = $(this); var boxval = $("#content").val(); var dataString = 'content='+ boxval; if(boxval=='') { alert("Please Enter Some Text"); } else { $("#flash").show(); $("#flash").fadeIn(400).html('<img src="ajax.gif" align="absmiddle"> <span class="loading">Loading Update...</span>'); $.ajax({ type: "POST", url: "update_ajax.php", data: dataString, cache: false, success: function(html){ $("ol#update").prepend(html); $("ol#update li:first").slideDown("slow"); document.getElementById('content').value=''; $('#content').value=''; $('#content').focus(); $("#flash").hide(); $("#expand_url").oembed(boxval); } }); } return false; }); //comment slide $('.comment').live("click",function() { var ID = $(this).attr("id"); $(".fullbox"+ID).show(); $("#c"+ID).slideToggle(300); return false; }); //commment Submint $('.comment_submit').live("click",function() { var ID = $(this).attr("id"); var comment_content = $("#textarea"+ID).val(); var dataString = 'comment_content='+ comment_content + '&msg_id=' + ID; if(comment_content=='') { alert("Please Enter Comment Text"); } else { $.ajax({ type: "POST", url: "comment_ajax.php", data: dataString, cache: false, success: function(html){ $("#commentload"+ID).append(html); document.getElementById("textarea"+ID).value=''; $("#textarea"+ID).focus(); } }); } return false; }); // Delete Wall Update $('.delete_update').live("click",function() { var ID = $(this).attr("id"); var dataString = 'msg_id='+ ID; var parent=$("#bar"+ID); jConfirm('Are you sure you want to delete this message?', 'Confirmation Dialog', function(r) { if(r==true) { $.ajax({ type: "POST", url: "delete_comment.php", data: dataString, cache: false, success: function(html){ $("#comment"+ID).slideUp(); } }); } return false; }); return false; }); }); </script> <style type="text/css"> body { font-family:Arial, Helvetica, sans-serif; font-size:12px; } .update_box { background-color:#D3E7F5; border-bottom:#ffffff solid 1px; padding-top:3px } a { text-decoration:none; color:#d02b55; } a:hover { text-decoration:underline; color:#d02b55; } *{margin:0;padding:0;} ol.timeline {list-style:none;font-size:1.2em;}ol.timeline li{ display:none;position:relative; }ol.timeline li:first-child{border-top:1px dashed #006699;} .delete_button { float:right; margin-right:10px; width:20px; height:20px } .cdelete_button { float:right; margin-right:10px; width:20px; height:20px } .feed_link { font-style:inherit; font-family:Georgia; font-size:13px;padding:10px; float:left; width:350px } .comment { color:#0000CC; text-decoration:underline } .delete_update { font-weight:bold; } .cdelete_update { font-weight:bold; } .post_box { height:55px;border-bottom:1px dashed #006699;background-color:#F3F3F3; width:499px;padding:.7em 0 .6em 0;line-height:1.1em; } #fullbox { margin-top:6px;margin-bottom:6px; display:none; } .comment_box { display:none;margin-left:90px; padding:10px; background-color:#d3e7f5; width:300px; height:50px; } .comment_load { margin-left:90px; padding:10px; background-color:#d3e7f5; width:300px; height:30px; font-size:12px; border-bottom:solid 1px #FFFFFF; } .text_area { width:290px; font-size:12px; height:30px; } #expand_box { margin-left:90px; margin-top:5px; margin-bottom:5px; } embed { width:200px; height:150px; } *{ margin:0px; padding:0px } ol.timeline { list-style:none } ol.timeline li { position:relative; border-bottom:1px #dedede dashed; padding:8px; } .morebox { font-weight:bold; color:#333333; text-align:center; border:solid 1px #333333; padding:8px; margin-top:8px; margin-bottom:8px; -moz-border-radius: 6px; -webkit-border-radius: 6px; } .morebox a{ color:#333333; text-decoration:none} .morebox a:hover{ color:#333333; text-decoration:none} #container{margin-left:60px; width:580px } </style> </head> <body> <?php include '../../../settings.php'; ?> <div align="center"> <table cellpadding="0" cellspacing="0" width="500px"> <tr> <td> <div align="left"> <form method="post" name="form" action=""> <table cellpadding="0" cellspacing="0" width="500px"> <tr><td align="left"><div align="left"> <h3>What are you doing?</h3></div></td></tr> <tr> <td style="padding:4px; padding-left:10px;" class="update_box"> <textarea cols="30" rows="2" style="width:480px;font-size:14px; font-weight:bold" name="content" id="content" maxlength="145" ></textarea><br /> <input type="submit" value="Update" id="v" name="submit" class="comment_button"/> </td> </tr> </table> </form> </div> <div style="height:7px"></div> <div id="flash" align="left" ></div> <ol id="update" class="timeline"> </ol> <ol class="timeline" id="updates"> <div id='old_updates'> <?php $small=mysql_query("select * from messages2 order by msg_id desc LIMIT 5"); while($r=mysql_fetch_array($small)) { $id=$r['msg_id']; $msg=$r['message']; ?> <div align="left" class="post_box"> <span style="padding:10px"><?php echo $msg.'....'.$id; ?> </span> </div> <?php //Here $id is main message msg_id value. $csql=mysql_query("select * from comments where msg_id_fk='$id' order by com_id "); $array = mysql_fetch_assoc($csql); $comment_count=mysql_num_rows($csql); if($comment_count>2) { $second_count=$comment_count-2; ?> <div class="comment_ui" id="view<?php echo $id; ?>"> <a href="#" class="view_comments" id="<?php echo $id; ?>">View all <?php echo $comment_count; ?> comments</a> </div> <?php } ?> <div id="view_comments<?php echo $id; ?>"></div> <div id="two_comments<?php echo $id; ?>"> <table width="80%"> <?php $small2=mysql_query("select * from comments where msg_id_fk='$id' order by com_id limit 2 "); while($rowsmall22=mysql_fetch_array($small2)) { $c_id=$rowsmall22['com_id']; $comments=$rowsmall22['comment']; ?> <div class="comment_actual_text"> <tr> <td style="BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid" valign="top"> <table style="WIDTH: 100%; BORDER-COLLAPSE: collapse" align="left"> <tr> <td width="5%" style="VERTICAL-ALIGN: middle; TEXT-ALIGN: center"><img style="WIDTH: 30px; HEIGHT: 30px" alt="srinivas" src="http://www.gravatar.com/avatar.php?gravatar_id=7a9e87053519e0e7a21bb69d1deb6dfe" border="1" /></td> <td style="VERTICAL-ALIGN: top; TEXT-ALIGN: left"> <strong>Jarratt</strong> <?php echo $comments; ?> <br /><span style="COLOR: #a9a9a9">10 min ago - ID = <?php echo $c_id.'...'.$id;?> </span></td> </tr> </table><br /> </td> </tr> </div> <?php } ?> </table> </div> <?php } ?> </ol> <div id="more<?php echo $id; ?>" class="morebox"> <a href="#" class="more" style='display:block;width:100%;' id="<?php echo $id; ?>">more <?php echo $id; ?></a> </div> </div> </td> </tr> </table> </div> </body> </html> if it help here is ajax_more.php PHP Code: <?php include("../../../settings.php"); if(isSet($_POST['lastmsg'])) { $lastmsg=$_POST['lastmsg']; $lastmsg=mysql_real_escape_string($lastmsg); $small=mysql_query("select * from messages2 WHERE msg_id<'$lastmsg' order by msg_id desc LIMIT 2"); while($r=mysql_fetch_array($small)) { $id=$r['msg_id']; $msg=$r['message']; ?> <div align="left" class="post_box"> <span style="padding:10px"><?php echo $msg.'....'.$id; ?> </span> </div> <?php //Here $id is main message msg_id value. $csql=mysql_query("select * from comments where msg_id_fk='$id' order by com_id "); $array = mysql_fetch_assoc($csql); $comment_count=mysql_num_rows($csql); if($comment_count>2) { $second_count=$comment_count-2; ?> <div class="comment_ui" id="view<?php echo $id; ?>"> <a href="#" class="view_comments" id="<?php echo $id; ?>">View all <?php echo $comment_count; ?> comments</a> </div> <?php } ?> <div class="comments" id="view_comments<?php echo $id; ?>"></div> <div id="two_comments<?php echo $id; ?>"> <table width="50%"> <?php $small2=mysql_query("select * from comments where msg_id_fk='$id' order by com_id limit 2 "); while($rowsmall22=mysql_fetch_array($small2)) { $c_id=$rowsmall22['com_id']; $comments=$rowsmall22['comment']; ?> <div class="comment_actual_text"> <tr> <td style="BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid" valign="top"> <table style="WIDTH: 100%; BORDER-COLLAPSE: collapse" align="left"> <tr> <td width="5%" style="VERTICAL-ALIGN: middle; TEXT-ALIGN: center"><img style="WIDTH: 30px; HEIGHT: 30px" alt="srinivas" src="http://www.gravatar.com/avatar.php?gravatar_id=7a9e87053519e0e7a21bb69d1deb6dfe" border="1" /></td> <td style="VERTICAL-ALIGN: top; TEXT-ALIGN: left"> <strong>Jarratt</strong> <?php echo $comments; ?> <br /><span style="COLOR: #a9a9a9">10 min ago - ID = <?php echo $c_id.'...'.$id;?> </span></td> </tr> </table><br /> </td> </tr> </div> <?php } ?> </table> </div> <?php } ?> <div id="more<?php echo $id; ?>" class="morebox"> <a href="#" class="more" style='display:block;width:100%;' id="<?php echo $id; ?>">more <?php echo $id; ?></a> </div> <?php } ?> Hi! I have been working on an assignment, and I seem to have things working okay, except that I'd like for the results (Message + list of 3 favorite movies or books) to show up in the Results box of the original page, not in a separate page. I'm sure it's something totally obvious that I'm missing, but I'm a newbie, and would appreciate any hints or tips that you all could give me. Thanks so much in advance! Heather W Hey I'm trying to create an aggregates calculator where the sum & average are calculated from the user inputs textarea of values, which i have split(). This is my code so far. I'm sure I'm not using the variables or parseFloat method correctly. Any advise? Many Thanks <html> <head> <script type="text/javascript"> <!-- function add() { document.getElementById("answer").value+=(document.getElementById("num1").value) + '\n'; } function calculate() { var total = "sa"; var sa = textAreaText.split("\n"); for (var i=0; i < sa.length; i++) parseFloat(sa[i]) + total; { document.getElementById("sum").value = total; } { document.getElementById("average").value = total / sa.length; } } //--> </script> </head> <body> <h1>Aggregates</h1> <h3>Add as many numbers as you like<br>to the list,then click Calculate.</h3> <form name="entryForm" id="entryForm"> <input type="text" id="num1"></input> <input type="button" value="Add to list" onclick="add();"><br> <textarea name="text" rows="15" cols="20" readonly="readonly" id="answer"></textarea><br> <input type="button" value="Calculate" onclick="calculate"> <input type="reset" value="Reset"> <p>Total (Sum);</p> <input type="text" id="sum" value="0"><br> <p>Average :</p> <input type="text" id="average" value="0"> </form> </body> </html> Right, so there are a bunch of links in this format: <a href="/profiles/########">username</a> I'm using greasemonkey, and what I want to do is go through and get all of the /profiles/######## part of the anchor tag. I'm using Regex and I can't seem to get a match. This is what I have so far: Code: function ok() { var names = document.getElementsByTagName('a'); var reg = new RegExp("WHAT GOES HERE?"); var e = "links:\n"; var i = 0; while(i<10) { e += reg.exec(names[i].href) + "\n"; i++; } alert(e); } ok(); what is actually desired is I want there to be a way I can select these somehow as well.. I need to be able to get the last value saved in document.cookie. My current script creates a cookie every time a new value is chosen in a drop down menu. Is there anyway to do this? Hi, I'm creating an extension on Firefox that wishes to parse the source of a page that the user is currently viewing for specific information. I've gotten as far as creating a simple extension with a button and when I click on it, it will show the url of the page I am currently viewing through: content.location.href All the examples I've seen so far concerning viewing the source forces you to either use the 'view-source:' convention or the 'xmlhttprequest' method. But these examples seems to be meant to be called within a web page and not an extension. When I cut and paste with these examples, I only get the source for the actual chrome portion of Firefox. I've tried modifying some of the examples to include 'content.document....etc' to reference what's being displayed in the browser, but it doesn't seem to work. Can anyone provide sample or reference code so I can extract the page source of my current window from an extension? Thanks! New to this, worked through the w3c tutorials and am really fascinated by some of the concepts. I'm only familiar with html, css, js (basics), so am trying to keep things as simple as I can for this. For simplicity I'll use books.xml with a listing of books. Each book has a <title><author><year><price> and <image> element. The images are stored in a folder called "images" a path is listed in the xml document. Using js and an array I can loop through the xml file and have it extract each node into a table, if I mouseOver a ROW in the table, it displays that listing in a DIV above and I would like it to display the image/thumbnail for that particular listing within another div called thumbnail which is in the same location regardless of which listing you mouseOver. Quote: if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","books.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; x=xmlDoc.getElementsByTagName("book"); i=0; function displayBook(i) { title=(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue); author=(x[i].getElementsByTagName("author")[0].childNodes[0].nodeValue); year=(x[i].getElementsByTagName("year")[0].childNodes[0].nodeValue); price=(x[i].getElementsByTagName("price")[0].childNodes[0].nodeValue); genre=(x[i].getElementsByTagName("genre")[0].childNodes[0].nodeValue); txt="Author: "+author+"<br />Title: "+title+ "<br />Year: "+year+"<br />Price: "+price + "<br />Category: " +genre; document.getElementById("showBook").innerHTML=txt; } Quote: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <script type="text/javascript" src="myscript.js"></script> <link rel="stylesheet" type="text/css" href="stylin.css" /> </head> <body onload="displayBook(0)"> <div id="wrap" width="40%"> <div id="desc">Listing: </div> <div id='showBook'></div><br /> <div id="thumbnail">thumbnail <script type="text/javascript"> document.write(????????????????); </script></div> <script type="text/javascript"> document.write("<table border='1'; >"); document.write("<caption>Mouse over a cell to view description:</caption"); document.write("<tr><td class=top>Book Title</td><td class=top>Category</td><td class=top>Cost: </td></tr>"); for (var i=0;i<x.length;i++) { document.write("<tr onMouseOver='displayBook(" + i + ")'; >"); document.write("<td>"); document.write(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue); document.write("</td><td>"); document.write(x[i].getElementsByTagName("genre")[0].childNodes[0].nodeValue); document.write("</td><td>" + "$"); document.write(x[i].getElementsByTagName("price")[0].childNodes[0].nodeValue ); document.write("</td><td>"); document.write(x[i].getElementsByTagName("image")[0].childNodes[0].nodeValue ); document.write("</td></tr>"); } document.write("</table>"); </script></div></div> </body> </html> So the way this looks is there's a grey div. At the top it says listing, and when the body loads it lists the [0] first entry from the array. To the right of this is a small div called thumbnail that is empty and I would like it to load the relevant image from the path in the <image> tag in the xml file. Below the listing is a table with 4 columns (title, genre, price, image) and an equal number of rows to the number of listings in the xml file. Under the "image" column it just shows the path to the image. So how do I tie the empty thumbnail div to the listing so it'll just add the path from the xml <image> tag into a <img src="pathnamefromxmldocument"> Thanks in advance! Well after much trial and error I come asking for help. I am trying to write a greasemonkey script that scans a page for all the values between certain <td> tags. When I used firebug it shows what I am looking for as <td class="username">THEUSERNAME</td> but when I view the source it just shows up as <td>THEUSERNAME</td> I want to create an array of the 100 <td>'s on the page that pertain to usernames but none of the other <td>'s I created a test page that mimicked the code, what I thought origionally, to be so I could test my script with ease. And it worked when there was an actually <td class="username"> This is what I have so far: Code: // ==UserScript== // //Displayable Name of your script // @name EXAMPLE // // brief description // @description EXAMPLE // //URI (preferably your own site, so browser can avert naming collisions // @namespace http://something.com // // Your name, userscript userid link (optional) // @author ME // //Version Number // @version 1.0 // // Urls process this user script on // @include http://example.com // ==/UserScript== var test = document.getElementsByClassName('username'); alert(test.length); test[5].style.color="yellow"; //Just to see if it actually worked disregard...i got it
Hello all. I'm working on a project for school and for the life of me I cannot get this to display properly. I'm trying to write a page where a user inputs their billing/shipping info and can click on a box to have it copied over to the opposite form. I've gotten code from several different places, including my text book, but when I call the external .js file, nothing happens. Code: <script type="text/javascript" src="display.js"> </script> I have a separate .js file that I am also using, with similar code that functions perfectly, except when I just add this code to the file, then none of it loads. The only reason that I have this in a .js file is that my XHTML needs to validate in strict. Code: function FillBilling(f) { if(f.billingtoo.checked == true) { f.billingCame.value = f.shippingName.value; f.billingAddress.value = f.shippingAddress.value; f.billingCity.value = f.shippingCity.value; f.billingState.value = f.shippingState.value; f.billingZip = f.shippingZip.value; /* If more fields are used, just expand the parameters above to include the additional fields. */ } } document.write("<form action='FormProcessor.html' name='display' method='get' enctype='application/x-www-form-urlencoded' onsubmit='return confirmSubmit()'>>"); document.write("Shipping Information"); document.write("Name:"); document.write("<input type='text' name='shippingName' size='50'>"); document.write("<br>"); document.write("Address:"); document.write("<input type='text' name='shippingAddress' size='50'>"); document.write("<br>"); document.write("City:"); document.write("<input type='text' name='shippingCity' size='25'>"); document.write("<br>"); document.write("State:"); document.write("<input type='text' name='shippingState' size='2' maxlength='2'>"); document.write("Zip Code:"); document.write("<input type='text' name='shippingZip' size='10'>"); document.write("<input type='checkbox' name='billingtoo'"); onclick='FillBilling(this.form)'> document.write("<br>"); document.write("<br>"); document.write("<em>Copy to billing fields.</em>"); document.write("<br>"); document.write("Billing Information"); document.write("<br>"); document.write("Name:"); document.write("<input type='text' name='billingName' size='50'>"); document.write("<br>"); document.write("Address:"); document.write("<input type='text' name='billingAddress' size='50'>"); document.write("<br>"); document.write("City:"); document.write("<input type='text' name='billingCity' size='25'>"); document.write("<br>"); document.write("State:"); document.write("<input type='text' name='billingState' size='2' maxlength='2'>"): document.write("Zip Code:"); document.write("<input type='text' name='billingZip' size='10'>"); document.write("<input type='submit'>"); document.write("<input type='reset'>"); document.write("</form>"); please help me. Hi everyone, I only know basic programing and was hoping someone can give me a hand with implementing checkboxes. What I'm hoping to achieve is a form that will have a number of checkboxes that, when a box is checked, the text corresponding to said box will be logged at the bottom of the page. Each checkbox will also have a numerical value which will display the tally at the bottom. for example, I might have the following two boxes Box 1: I have a Bike +3 box 2: I have a Car +5 When both boxes are checked, the log at the bottom would read: I have a Bike +3 I have a Car +5 Total = +8 Code: <form action=""> <input type="checkbox" name="vehicle" value="Bike" /> I have a bike +3<br /> <input type="checkbox" name="vehicle" value="Car" /> I have a car +5 </form> OK I am wanting to build a table that I can enter data in to and have people sort by a drop down box like the 4th table down on this list -- http://www.javascriptkit.com/script/...lefilter.shtml But I have followed those instructions step by step and it never works. I was told to use .asp I have changed my page to a .asp and now have no clue where to go from here. In searching this site I have found this code -- [CODE] <script> function Filter(table){ var f=document.getElementById('f').value.toUpperCase(); for (a=1; a<table.rows.length; a++) { if (table.rows[a].cells[0].innerHTML.toUpperCase().indexOf(f)!=0) table.rows[a].style.display="none"; else table.rows[a].style.display="table-row"; } } </script> <table id="states" border=1> <tr><td>State</td><td>Code</td></tr> <tr><td>ALABAMA</td><td>AL</td></tr> <tr><td>ALASKA</td><td>AK</td></tr> <tr><td>MAINE</td><td>ME</td></tr> <tr><td>MARSHALL ISLANDS</td><td>MH</td></tr> </table> <form> <input type="text" name="f" id="f"> <input type="button" value="Filter" onclick="Filter(document.getElementById('states'));"> </form> [CODE] But it gives me a filter that I have to type in. I am looking for drop downs that allow me to filter so say you select drop down for fields that contain "A" then another drop down for a field that contains "B" so the results show fields that contain "A" and "B" And PS I am semi new to the code world so please don't assume I know some stuff dumb it down a little HAHA hi, the yahoo function below is for dragging a box around teh screen Code: (function() { var Dom = YAHOO.util.Dom, Event = YAHOO.util.Event, dd1, dd2, dd3; YAHOO.example.DDRegion = function(id, sGroup, config) { this.cont = config.cont; YAHOO.example.DDRegion.superclass.constructor.apply(this, arguments); }; YAHOO.extend(YAHOO.example.DDRegion, YAHOO.util.DD, { cont: null, init: function() { //Call the parent's init method YAHOO.example.DDRegion.superclass.init.apply(this, arguments); this.initConstraints(); Event.on(window, 'resize', function() { this.initConstraints(); }, this, true); }, initConstraints: function() { //Get the top, right, bottom and left positions var region = Dom.getRegion(this.cont); //Get the element we are working on var el = this.getEl(); //Get the xy position of it var xy = Dom.getXY(el); //Get the width and height var width = parseInt(Dom.getStyle(el, 'width'), 10); var height = parseInt(Dom.getStyle(el, 'height'), 10); //Set left to x minus left var left = xy[0] - region.left; //Set right to right minus x minus width var right = region.right - xy[0] - width; //Set top to y minus top var top = xy[1] - region.top; //Set bottom to bottom minus y minus height var bottom = region.bottom - xy[1] - height; //Set the constraints based on the above calculations this.setXConstraint(left, right); this.setYConstraint(top, bottom); } }); I would like to show the final TOP and LEFT results in textboxes onMouseUP?! thanks in advance! |