JavaScript - Urgent::how Do I Get Data Into A Dojo Border Container Using Ajax?
I am doing a project and I have a problem. I have retrieved data from a json file using ajax and the xmlhttprequest, but I am not able to put the content I retrieve into the dojo content pane. The content pane is inside a border container.
I have tried the following, but it does not work. The HTMLPage4.html has the json data inside. please help me really urgent to me!!!!!!!as soon as possible Code: function getInfoContent(graphic) { function ajaxRequests() { var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE if (window.ActiveXObject) { //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken) for (var i = 0; i < activexmodes.length; i++) { try { return new ActiveXObject(activexmodes[i]) } catch (e) { //suppress error } } } else if (window.XMLHttpRequest) // if Mozilla, Safari etc return new XMLHttpRequest() else return false } var mygetrequests = new ajaxRequests() mygetrequests.onreadystatechange = function() { if (mygetrequests.readyState == 4) { if (mygetrequests.status == 200 || window.location.href.indexOf("http") == -1) { var bookss = eval("(" + mygetrequests.responseText + ")") //retrieve result as an JavaScript object var rssent = bookss.infos.info for (var i = 0; i < rssent.length; i++) { // alert(mygetrequests.responseText); var placeImg = "" var txt = "" // placeImg += rssent[i].descImg txt += rssent[i].desc var shorttxt = "" shorttxt += txt.substring(0, 30); var bc = new dijit.layout.BorderContainer({ style: "font-size: 11pt; height: 574px; width:739px; border:0px;" }); var c1 = new dijit.layout.ContentPane({ region: "top", style: "height: 11.5%; width: 100%; color: black; background-color: transparent; border:0px;", content: "<table><div id = \"mydiv\">" + shorttxt + "<font color = '#0000FF' size = '1'><a onclick='showmore();'><u> More...</u></a></div></td></table>" }); bc.addChild(c1); } } else { alert("An error has occured making the request") } } return bc.domNode; } mygetrequests.open("GET", "HTMLPage4.htm", true) mygetrequests.send(null) } Similar Tutorialshii i am doing a project and i meet some problem i create a dojo dialog box i need to style the dialog box into whole thing white but i am not able to style the border (the grey line) between the title and content so i was wondering how am i goin to style it into white? i don't use the css to style it so i was wondering how to write it like " noteDlg.titleBar.style.background = 'white'; " this kind to remove the grey line between the title and content thanks ps. I really need it very urgently...hope reply asap function note(){ noteDlg = new dijit.Dialog({ title: "Programatic Dialog Creation", draggable: false, style: "width: 300px; border:0px; " }); // set the content of the dialog: noteDlg.attr("content", "Hey, I wasn't there before, I was added at "); noteDlg.titleBar.style.background = 'white'; noteDlg.show(); } hi i recently working on a project i need to create hard code first of list of element something like the below of code but i not sure if i declare this array correctly? var it = [{ "id": "1001", "type": "Regular" },{ "id": "1002", "type": "Chocolate" },{ "id": "1002", "type": "Blueberry" },{ "id": "1004", "type": "Devil's Food" }] secondly, i want to show all the data that have same id..so how should do ? must i for loop and if loop...cause i know need to if loop....is it meaning using continue statement i need to show in when i click on a link and those with the same id will display in the dialog can show any example PS...reply asap!!! thanks!!!!!! hi i am doing a project and now i am try to work on paging, however i am stuck. I want to put in a list of links of website in the itemfilereadstore. So when show, i want to be able to click on any one of the link in the page, which will bring you to the selected website reference guide: http://dojotoolkit.org/reference-gui...agination.html In my latest project I have integrated dojo.There I have have a Dnd functionality in which I have to drag a dndItem into a textarea. For this I have converted the textarea to a dojoDnd Target with the dojoType attribute. Now the problem is the target textarea accepts dnd items only in explorer , opera and chrome.But this doesn't works in mozilla.Since my application runs only in mozilla I cannot proceed any more till I get out of this problem. Can you help me out of this? hi anyone know how to style the dojo button cause i declare the button it appear but i cannot use the style:"border:0px; background-color: black;" this is how i declare my dojo button var forward = new dijit.form.Button({ style: "border:0px;background:black;", label: "NEXT" }); Please help me with this !!! Please Reply ASAP!!! Thanks p.s if can show me some sample Hi there How to send data from a text feild in GET method using an AJAX call... I already have codes working Code: to = "interfaces/add_department.jsp"; parm = "name="+name.value+ "&name2="+name2.value; alert(parm) post(to,parm,callBackFunctionForAddDepartment); Here the variable name may have "me&you" or "me you" like that.... so how do i encode it so that it reaches properly? hey another know how can i change the background color of the title bar in the dojo dialog box? cause i search and i couldn't find any way.... Please help me and reply asap Thanks p.s if can show me sample code of how to change I have recentley decided to move from prototype to DOJO. I have the latest 1.3.2 and i am having problems accessing the themepage.html They tell you in their documents that you can install it on the server, place the files on the server or install it locally. So i installed it in my files on site. They tell you to go to: "http://your-webpage.com/js/dojo-1.3.2/dijit/themes/themeTester.html" when looking locally through my files their isn't a page like that. What page should i look at to view the widgets? Thank you for any help. Scenario: Client Side : Simple functions that have events tied to different elements. Each time an event is triggered the function begins an Ajax call to an external server side page filled with JS functions. Server Side : Our client side AJAX call sends the name of the function we want to call out on this file. Once called and performed, it returns DOM edits that could be fired once our client side page receives the data back from Ajax. I know that data being returned from Ajax is always a string. But would it be possible? I mean could the server side file send out commands or rather DOM edits that the client side could pick up on and perform? I am almost 100% certain the answer is no due to JS needing to be cached in the browser and what not, but I figured I would ask the experts anyways. BTW: objective is to move sensitive core JS functions to prevent online application theft... without Flex or Air. Hi, I have a problem with sending data from a form to a php script with AJAX. To test if it works, I try to send data from the form, print it in the php with "echo", and then put it back in the initial html file. My Javascript code is: Code: function registerPrivateUser() { xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Your browser does not support AJAX!"); return; } var postData="firstName="+ document.getElementById("txtFirstName").value; var url="classes/users/checkRegistration.php"; xmlhttp.onreadystatechange=stateChanged; xmlhttp.open("POST",url,true); //xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); xmlhttp.send(postData); } The function stateChanged, basically says: Code: if (xmlhttp.readyState==4) { var strResponse; strResponse=xmlhttp.responseText; alert('Response:' + xmlhttp.responseText); } checkRegistration.php looks like this: PHP Code: <? session_start(); $firstName=$_POST['firstName']; echo($firstName); ?> The problem is that the response is empty, but I don't know why. I have checked the input data and the postData variable says "firstName="+input (e.g. "firstName=Robert"), so that's not the error. I have read several forum posts here, but still haven't figured out what I'm doing wrong. If anyone could please tell me, I would appreciate it alot. I'm using jquery right now but I sort of understand what the problem is. I'm making a file manager and when you click on an li tag it will do some action depending on if it's a file type or a folder type. There are 3 important files you should know about. 1. filemanager.php (Where the file managing takes place. Starts by including filemanager_getfile.php and including filemanager.js in the head). 2. filemanager_getfile.php (Information that receives information from the ajax request [the directory to be read] and prints the new file list in <li> tags) 3. filemanager.js (Jquery that processes li clicks) The problem is, when you click on a folder (and it loads the new information from the ajax request) the jquery doesn't check the new li tags when clicked (I'm guessing when you first link the javascript file it has to compile all of the current li information?). Try it for yourself- [removed] Instruction (if it's not already obvious): -Clicking a file selects if. If files are selected and you click the arrow in the file options it will transfer it (not really, but it will later). -Clicking a folder will send an ajax request with the new directory information to be checked and return the html -Clicking the '?' in the file options will display the pages html (I implemented it to debug). I have tried linking the js page every time I include the new directory information, but the js stacks on each other. So if I click on 3 folders and hit the '?' button it will display the page html 3 times. And if I select the index.php li and click transfer, it will "transfer" 3 times. filemanager.php Code: <div id="goldenSub"> <div class="title">Golden Subdomain</div> <div class="files" id="goldenSubFiles"> <? include("filemanager_getfiles.php"); ?> </div> <div id="history" visited="goldensub/"></div>; <div class="fileOptions"><img src="images/question.png" title='HTML Information' id="ask"><img src="images/transferto.png" title='Copy File To' id="transferTo"></div> </div> filemanager_getfiles.php PHP Code: <? $path = $_REQUEST["dir"]; if($path == "" || $path == null) { $path = 'goldensub/'; } echo "\n<div class='path'>$path</div>\n<ul>\n"; $handler = opendir($path); //We need to organize the results. Be default, all files and folders will be //located by alphabetical order. But we want to list all folders first, followed //by files. By adding the results to arrays first we can decide to print our //results in the order we want. $folderArray = array(); $fileArray = array(); $folderCount = 0; $fileCount = 0; while(false !==($file=readdir($handler))) { if($file != "" && $file != null && $file != "." && $file != "..") { $extensionLocation = strrpos($file, "."); //Is this a folder or a file? if($extensionLocation == null && $extensionLocation == "") { //This is a folder unless it's the error_log file. if($file != "error_log") { //Nope, it's definitly a folder. Add it to the folder array. $folderCount++; $folderArray[$folderCount] = $file; } } else { //This is a file. Add it to the file array. $fileCount++; $fileArray[$fileCount] = $file; } } } if($path != 'goldensub/') { echo "\t<li title='goldensub/' type='folder'>\n\t\t<img src='images/up.png'> goldensub\n\t</li>\n"; } for($i = 1; $i<=$folderCount; $i++) { $newPath = $path.$folderArray[$i].'/'; echo "\t<li title='$newPath' type='folder'>\n\t\t<img src='images/folderOpen.png'> $folderArray[$i]\n\t</li>\n"; } for($i = 1; $i<=$fileCount; $i++) { $extensionLocation = strrpos($fileArray[$i], "."); $nameLength = strlen($fileArray[$i]); $extensionLength = $nameLength-$extensionLocation; $nameClean = substr($fileArray[$i], 0, $extensionLocation); $extension = substr($fileArray[$i], $extensionLocation+1, $nameLength); echo "\t<li title='$fileArray[$i]' type='file' extension='$extension'>\n\t\t\n\t<img src='images/$extension.png'> $nameClean\n\t</li>\n"; } echo "</ul>"; ?> filemanager.js Code: $("li").click(function(){ var type = $(this).attr("type"); //This is a folder if(type == "folder") { //Path to new directory var newPath = $(this).attr("title"); //Ajax request to filemanager_getfiles.php $("#goldenSubFiles").load("filemanager_getfiles.php", { dir: newPath }, function(data){ //Update log newLog("Directory changed to <i><b>"+newPath+"</b></i>"); }); } //This is a file else { if($(this).hasClass("selected")) { //It's already selected - deselect it. $(this).removeClass("selected"); } else { //Select it $(this).addClass("selected"); } } }); 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. Hi, i am new to javascript and i am giving a task to create a javascript page, i need a javascript that will calculate and generate a simple Quotation with total price of item selected and its quantity in a new page and in tabular form, i need this for 2 check-boxs that has the value, 2 dropdownlist and the price.
I'm a newbie to php and javascript. I want some checkbox to hide some rows of my table so i did a search and i found a few javascript codes but yet I couldn't make it work the way I wanted it. When I uncheck a checkbox ONLY the first table rows get hidden, the other tables don't? can't I ID some rows? Please I need help :( My javascript code is: Quote: <script type="text/javascript"><!-- function showHideTR(idx,vis) { var tbl,row; if(document.getElementById && document.getElementsByTagName) { tbl = document.getElementById('tbl'); if(!tbl || (idx >= tbl.getElementsByTagName('tr').length)) return; row = tbl.getElementsByTagName('tr')[idx]; } else if(document.all && document.all.tags) { // IE4 support tbl = document.all.tbl; if(!tbl || (idx >= tbl.all.tags('tr').length)) return; row = tbl.all.tags('tr')[idx]; } if(row) { if(!vis) { row.style.display = 'none'; } else { // conditional compilation to hide the try-catch blocks from IE4 /*@cc_on @if(!@_jscript || (@_jscript_version >= 5)) @*/ try { row.style.display = 'table-row'; } catch(e) { row.style.display = 'block'; } /*@elif(@_jscript_version < 5) row.style.display = 'block'; // for IE4 @end @*/ } } } function getStyle(el,styleProp) { var x = (typeof(el)=='string')?document.getElementById(el):el; if (x.currentStyle) var y = x.currentStyle[styleProp]; else if (window.getComputedStyle) var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp); return y; } window.onload = function() { if(!document.getElementsByTagName) return; var tds = document.getElementsByTagName('td'); for(var i=0;i<tds.length;i++) { tds[i].onclick = function() { alert(this.parentNode.tagName+' = display : '+getStyle(this.parentNode,'display')+ '\n'+this.tagName+' = display : '+getStyle(this,'display')); } } } // --> </script> <!-- <script type="text/javascript"> function showHideTR(idx,vis) { var tbl,val; val = (!vis)?'none':((document.defaultCharset && !window.home)?'block': 'table-row'); if(document.getElementById && document.getElementsByTagName) { tbl = document.getElementById('tbl'); if(idx >= tbl.getElementsByTagName('tr').length) return; tbl.getElementsByTagName('tr')[idx].style.display = val; } else if(document.all && document.all.tags) { // IE4 support tbl = document.all.tbl; if(idx >= tbl.all.tags('tr').length) return; tbl.all.tags('tr')[idx].style.display = val; } } </script> --> My option tags: Quote: <form action="#" onsubmit="return false;"> <ul> <li2><label for="cb0"><input type="checkbox" id="cb0" checked="checked" onclick="showHideTR(0,this.checked);"> Blah Blah</label></li> <li2><label for="cb1"><input type="checkbox" id="cb1" checked="checked" onclick="showHideTR(1,this.checked);"> Blah Blah2</label></li> <li2><label for="cb2"><input type="checkbox" id="cb2" checked="checked" onclick="showHideTR(2,this.checked);"> Blah Blah3</label></li> <li2><label for="cb3"><input type="checkbox" id="cb1" checked="checked" onclick="showHideTR(3,this.checked);"> Blah Blah4</label></li> </ul> </form> My php page: Quote: <?php $host = "localhost"; // your host name $username = "blah blah"; // your user name to access MySql $password = "blah blah"; // your password to access MySql $database = "blah blah"; // The name of the database $no = $_POST["sureno"]; //$link = mysql_connect($host,$username,$password); if (!$link = @mysql_connect($host,$username,$password,true)) {die('Could not connect:'. mysql_error()); } @mysql_query("SET NAMES 'latin5'"); @mysql_select_db($database) or die( "Unable to select database"); $sql="SELECT * FROM blah blah WHERE sure = '$no' ORDER BY 'id'"; $result = mysql_query($sql); if (!$result) { die('Invalid query: ' . mysql_error()); } while($row=mysql_fetch_assoc($result)){ $bgcolor="#f1f1f1"; echo "<TABLE width=50% align=center cellpadding=0 cellspacing=0 id='tbl' summary='demonstration'> <tr>"; echo "<td bgcolor='dfdfdf' ><font face='arial,verdana,helvetica' color='#000000' size='3'>blah blah</font></td>"; echo "<td bgcolor='C0C0C0' ><font face='arial,verdana,helvetica' color='#FF0000' size='4'>" . $row['AB'] ."</font></td></tr>"; echo "<tr><td bgcolor='dfdfdf' ><font face='arial,verdana,helvetica' color='#000000' size='3'>blah blah</font></td>"; echo "<td bgcolor='dfdfdf'> <font face='arial,verdana,helvetica' color='#0080C0' size='2'>". $row['TR'] ."</font></td></tr>"; echo "<tr><td bgcolor='dfdfdf' ><font face='arial,verdana,helvetica' color='#000000' size='3'>blah blah</font></td>"; echo "<td bgcolor='dfdfdf' id='cb0'> <font face='arial,verdana,helvetica' color='#000000' size='3'>". $row['ML'] ."</font></td></tr>"; } mysql_free_result($result); ?> Hi Guys, I am implementing this Javascript in my summer internship. What I want to do is, 1) Show a Pop up alert with a Countdown timer( 10, 9, 8, 7 ....) after 5 minutes. 2) If user doesn't click "Ok" within the time, the page will automatically Redirect to another page. Eg- Login Page. 3) If the User clicks the "Ok" button the Page will not get re-direct. 4) Also, once the Timer countdown completes and the page redirection is done, the User when he will see the Login page will see an alert box saying. 'Your session has expired, plz login again' he clicks 'Ok' and Login again. I am very new to this Java script, but need to finish this project. Plz help me out. Hi I'm trying to create a javascript function that will ask a user for a character and check that character against a string containing other characters. If the character is present in the string the function should then ask the user to input another character. it should keep doing this until a charater is entered that doesnt appear in the check string. I am pretty new to javascript and have been working for about 2 days trying to get this to work. I have an assignment due next week 21.09.09 and need to get it sorted before then. Any help or pointers would be great. One stipulation that the assignment is asking for is that you have to use the indexOf method to interigate the string. I have attached the code below. Any help or pointers would be brilliant. var incorrectString = 'abcdef'; var correctString = 'ghi'; function getInput(aString) { } getInput(incorrectString + correctString); I am a beginner so please help ASAP. When I validate my code in validate.w3.org: document.write("<img src='" + myNum +".jpg'/>"); I got an error that said: --- required attribute "alt" not specified can any one please help me out with the code. I am passing an URL for ex: www.example.com?req=23¶m=25 What i need to do is I need to remove the parameters after "?" which I did using the spilt method, Can anyone help me out now how do I send the complete URL with the parameters as hidden. what I mean is..my URL should look like www.example.com. but the second part (parameter shud be hidden). I have a page in html, containing some text like " ABCDEFGHIJKL" etc. This text has also a website link (hyperlink) with it. This website link changes on each refresh of page. Such link changes due to javascript runing behind on it. I just want this link each time stored in a PHP variable. Such text always appears on a certain position on the page (X,Y). Can you please help me on it.? I can provide additional details on request. Your early answer is required. Regards Ahmed Taufiq here's what I have so far Code: <html> <head> <script> MONTHS_OF_THE_YEAR = 'janfebmaraprmayjunjulaugsepoctnovdec'; MILLISECONDS_DAY = 1000*60*60*24; MILLISECONDS_YEAR = 1000*60*60*24*365.2424; LIFE_EXPECTANCY = 1000*60*60*24*365.2424*67.2; var daysArray = new Array ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); var yearBirth = ''; yearBirth = prompt('Please enter your year of birth'); var monthBirth = ''; monthBirth = prompt('Please enter your month of birth'); monthBirth = monthBirth.slice(0,3); monthBirth = monthBirth.toLowerCase(); monthBirth = MONTHS_OF_THE_YEAR.indexOf(''+monthBirth)/3; var dateBirth = ''; dateBirth = prompt('Please enter your date of birth'); var usersInputDate = new Date (yearBirth, monthBirth, dateBirth); var dd = new Date((monthBirth+1).toString() + "/" + dateBirth + "/" + yearBirth); dd=dd.getDay(); var now = new Date(); usersInputTime = (usersInputDate.getTime()); usersInputTime = parseInt(now.getTime()-usersInputTime); var ageYears = (usersInputTime/MILLISECONDS_YEAR); var ageDays = (usersInputTime/MILLISECONDS_DAY); var avgLife = (usersInputTime/LIFE_EXPECTANCY*100); document.writeln('<h1>It\'s about time...</h1>'); document.writeln('<ul>'); document.writeln('<li> </li>' </script> </head> <body> </body> </html> I need to do the following and have no idea Quote: What will be output (to the document using write())? A heading 1 title with the text It's about time... An unordered list containing appropriate wording as strings concatenated with: The weekday name for the user's birth date Use the day of the week number as an index into the weekday names array The user's age in years Present this as a fixed format number with 2 decimal places The user's age in days Present this as a fixed format number with 0 decimal places The percentage of an average life expectancy Present this as a fixed format number with 0 decimal places please help i need to get this done tonight |