JavaScript - Array And Dialog Box
Hey Scripters,
I need to complete a task for a friend and I am stuck at this part. I am new with Javascript but I'm his only friend that knows a bit of Javascript. So for this problematic part of my task, I need to use tables and dialog boxes. First of all I need to define an array of 3 elements. Each element is associated with a different first name. Then I shall realize a first function to add a name in the table. The function takes as parameter the table previously created and return it containing an additional element whose value is the name that the visitor wants to add. I must use the dialog box prompt so that the user can specify the name he wishes to add in the table. I shall also perform a second function which will display the name that is included in the different array elements. This function will also take the table in parameters and proceed with setting the display name with a dialog box alert type that contains all of the name separated by ";". Help is very much appreciated. Please don't post links, I need explanations, so that I can understand next time I encounter this situation. Similar TutorialsHi, Is there any way (any api) to display the confirm dialog box with yes/no buttons instead of ok/cancel in javascript. Can any one please let me know. Thanks in advance. I have created a button with a window.confirm() method but when I click on it in firefox the dialog box does not appear. It does however appear in all the other browsers
Hey guys, I've been experimenting around with a way to get a "Save As" dialog to pop up prompting the user to download a certain file from the server. How I've done this so far is open a window in Javascript to a PHP file, server side, passing an argument through _GET. The PHP generates the file and then sends a header request to download. Simple enough. The problem is that using this method opens a blank window in addition to the Save As Dialog. Is there anyway to fool the browser/ hide the window/ etc, so two windows don't pop up at the same time everytime my users press the download button? I am also pretty familiar with AJAX techniques, so if anyone has a solution along that route as well I'd appreciate it. Cheers, Q http://tinyurl.com/bw2y3sr This is my site and I want to create a Yes and No dialogue box when user closes a browser so this popup confirm dialogue should appear. Can anyone help me? I have searched this, I promise. But everything I've tried either does nothing or just opens a new window. All I want to be able to do is to have a button that when the user clicks on it, it will open a "save as" dialog box so they can save a file (a separate file, not the html one that they are looking at) from my server. Is this really not possible using javascript, or am I just completely confused again? I have a ZIP file in the server. I want create a create a save dialog to save the zip file in local machine. The below code works perfectly fine for firefox but not on IE. apparently I want the code to work in IE. this is 4th JS forum I am posting my question......any help is greatly appreciated. <html> <head></head> <script language='javascript'> function JBTRunZip( ){ location.href="IMAN_IMAGE_FILES.zip"; } function download(locate){ window.open(locate) } </script> <body> <button onclick="JBTRunZip()">generateZip</Button> <td><input type ="Button" value ="Scarica" onclick="download('Test.zip');"></td> </body> </html> Hello, I have some code to open 1 dialog box. Could someone please help me manipulate this code to open multiple boxes with different contents. I would like to do this with out duplicating the existing code, maybe setting a variable. The least amount of code the better. Thanks in advance. 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"> <meta charset="utf-8"> <title></title> <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-ui.css"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js"></script> </head><body> <div id="dialog" title="Example dialog"> <p>Some text that you want to display to the user.</p> </div> <script type="text/javascript"> $(document).ready(function() { $("#dialog").dialog({ bgiframe: true, autoOpen: false, height: 100, modal: true }); }); </script> <a href="#" onclick="jQuery('#dialog').dialog('open'); return false">Click here to see the popup</a> </body> </html> Hello, I have a dialog box and in there I have a button that says New Service. When a user clicks on New Service, another dialog is shown where they the put the name of the service and after they click Create, I want that dialog box and the first one close as well. Here is my code, I can't figure it out. I want the #create-userDialog box to close after the user clicks on Create in #new-serviceDialog. <script> $(function() { $( "#dialog:ui-dialog" ).dialog( "destroy" ); $( "#create-userDialog" ).dialog({ autoOpen: false, width: 600, modal: true, buttons: { "OPEN": function() { var bValid = true; allFields.removeClass( "ui-state-error" ); }, CLOSE: function() { $( this ).dialog( "close" ); } }, close: function() { allFields.val( "" ).removeClass( "ui-state-error" ); } }); $( "#create-user" ) .button() .click(function() { $( "#create-userDialog" ).dialog( "open" ); }); $( "#new-serviceDialog" ).dialog({ autoOpen: false, width: 400, modal: true, buttons: { "Create": function() { var bValid = true; onclick = $( this ).dialog( "close" ); allFields.removeClass( "ui-state-error" ); }, Close: function() { $( this ).dialog( "close" ); } }, close: function() { allFields.val( "" ).removeClass( "ui-state-error" ); } }); $( "#new-service" ) .button() .click(function() { $( "#new-serviceDialog" ).dialog( "open" ); }); }); </script> Here's the code. what am I missing to make this work? Thank you in advanced! @if (Model.Layer.Id > 0){ <div style="float: left; padding-left: 14px;"> @using (Html.BeginForm("Delete", "Layer", new { layerId = Model.Layer.Id, subAccountId = Model.SubAccount.Id })){ <input type="image" src="/Portal/Content/images/admin-delete-off-btn.png" onmouseover="this.src='/Portal/Content/images/admin-delete-on-btn.png'" onmouseout="this.src='/Portal/Content/images/admin-delete-off-btn.png'" title="Delete button" value="Delete" alt="Delete" /> } </div> } <div class="clear"></div> <div id="dialogDeleteBox" title="Delete Confirm" style="display: none"> <span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 40px 0;"></span> <div id="confirmDeleteLayer"> <div id="confirmDeleteLayerMessage"> <p> Are you sure you want to delete this group? </p> </div> </div> </div> Hey there guys, i've been having a problem lately and i can't seem to find any solution for that. I know you guys could help me, so here it goes: I have a javascript promt box (as you can see in the code below) it works perfectly fine with internet explorer however it's NOT working in firefox. I tried everything i can think of, but still its not working! Please check the code below and give me the solution for firefox. Thank You! <%@LANGUAGE="VBSCRIPT" CODEPAGE="28592"%> <!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-2" /> <title>Choose Your Language</title> <script language="javascript" type="text/javascript"> function checklang() { var lang = prompt('Choose A Language:'+'\n' + "(Ex: Armenian, Arabic, English, French, Greek, Russian)",'English'); if (lang==null || lang=="") {lang=""; return;} if (lang=="Armenian" || lang=="Arabic" || lang=="English" || lang=="French" || lang=="Greek" || lang=="Russian") {location.href = "sermon-section.asp?lang="+lang}; else location.reload(); } </script> </head> <body> <a href="#" onclick="checklang()">Choose Your Language</a> </body> </html> Hi! Trying to get a delete confirm dialog box to open when you click on the button. Here's what I have in the body... @if (Model.Layer.Id > 0){ <div style="float: left; padding-left: 14px;"> @using (Html.BeginForm("Delete", "Layer", new { layerId = Model.Layer.Id, subAccountId = Model.SubAccount.Id })){ <input type="image" src="/Portal/Content/images/admin-delete-off-btn.png" onmouseover="this.src='/Portal/Content/images/admin-delete-on-btn.png'" onmouseout="this.src='/Portal/Content/images/admin-delete-off-btn.png'" title="Delete button" value="Delete" alt="Delete" /> } </div> } I can't seem to figure out the script to make this work. Can anyone help? What I had was <script type="text/javascript"> function confirmDeleteSelected(id) { jQuery("#dialog-confirmDelete").dialog({ closeOnEscape: false, resizable: false, width: 250, modal: false, zIndex: 5000, buttons: { "Yes": function () { doDeleteSelected(id); jQuery(this).dialog("close"); jQuery(this).dialog("destroy"); }, "No": function () { jQuery(this).dialog("close"); jQuery(this).dialog("destroy"); } } //end Buttons }); } </script> Thanks Phil 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 Hi, i have an popup which is an aspx page and when i click on browser close button..., the system should check if there is any unsaved data in the form or not. If there is any unsaved data then the message should be displayed (Do you want to leave..?) with OK and Cancel button... On click of the OK button, the data should not be saved and the user should be returned parent form ie popup should be closed and return to the parent form.On click of the cancel button, the control should return to the Pop. I had tried the below code... window.onbeforeunload = close; function close() { var result=confirm("Do you really want to close this window"); if (result) { return true; } else { location.href = document.URL; } } The above code is not working ie the popup is getting closed even on click of closse button.... and when clicked on OK it is dispalying another msgbox with leave this page and Stay on this page buttons... Please help me regarding the same... I have written base rel="nofollow" target="_self" tag in head tag. It works fine in IE6 but not in IE8. window.showModalDialog() opens up new ModalDialog instead of using existing Dialog. Can anybody help me?
hii 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(); } I am working on a page where the user will select a location from a dynamically generated dropdown list. I was able to create the php multidimensional array (tested and working) from a MySql database using the users information at login, but I'm having problems converting it to a javascript multidimensional array. I need to be able to access variables that I can pass to a number of text fields within an html form. For instance, if a user belongs to a company with multiple addresses, I need to be able to let them select the address they need to prepopulate specific text fields. php array creation: Code: if ($row_locations) { while ($row_locations = mysql_fetch_assoc($locations)) { $mail[$row_locations['comp_id']]=array('mailto'=>$row_locations['mailto'], 'madd'=>$row_locations['madd'], 'madd2'=>$row_locations['madd2'], 'mcity'=>$row_locations['mcity'], 'mstate'=>$row_locations['mstate'], 'mzip'=>$row_locations['mzip'], 'billto'=>$row_locations['billto'], 'badd'=>$row_locations['badd'], 'badd2'=>$row_locations['badd2'], 'bcity'=>$row_locations['bcity'], 'bstate'=>$row_locations['bstate'], 'bzip'=>$row_locations['bzip']); } } javascript function - this should create the array and send variables to text fields. Code: function updateAddress() { var mail = $.parseJSON(<?php print json_encode(json_encode($mail)); ?>); { if (comp_id in mail) { document.getElementById('mailto').value=mail.comp_id.mailto.value; document.getElementById('madd').value=mail.comp_id.madd.value; document.getElementById('madd2').value=mail.comp_id.madd2.value; document.getElementById('mcity').value=mail.comp_id.mcity.value; document.getElementById('mstate').value=mail.comp_id.mstate.value; document.getElementById('mzip').value=mail.comp_id.mzip.value; } else { document.getElementById('mailto').value=''; document.getElementById('madd').value=''; document.getElementById('madd2').value=''; document.getElementById('mcity').value=''; document.getElementById('mstate').value=''; document.getElementById('mzip').value=''; } } } Where is this breaking? Thanks in advance. I have the following array that contain the people who are on off on certain time: Code: var all = [ ["1234", "Jim", "2011-10-23 00:00:00", "2011-10-25 07:00:00"], ["1235", "Jack", "2011-10-21 00:00:00", "2011-10-21 08:00:00"], ["1236", "Jane", "2011-10-11 00:00:00", "2011-10-11 00:30:00"], ["1237", "June", "2011-10-20 00:00:00", "2011-10-20 12:00:00"], ["1238", "Jill", "2011-10-14 00:00:00", "2011-10-14 11:00:00"], ["1239", "John", "2011-10-16 00:00:00", "2011-10-16 10:30:00"], ["1240", "Jacab", "2011-10-19 00:00:00", "2011-10-20 08:30:00"] ]; The above array, I wish to use javascript to insert into the FullCalendar (http://arshaw.com/fullcalendar/). I notice that the only way seems to be using the FullCalendar array style (or structure) as follows: Code: $('#calendar').fullCalendar({ events: [ { title : 'event1', start : '2010-01-01' }, { title : 'event2', start : '2010-01-05', end : '2010-01-07' }, { title : 'event3', start : '2010-01-09 12:30:00', allDay : false // will make the time show } ] }); So, the question is: How do I insert my array to match with the FullCalendar array? cause FullCalendar array had a different array structure from my array - and I don't think so that I can write in this way: Code: $('#calendar').fullCalendar({ events:all }); Appreciate any help provided. I can't seem to figure out how to accomplish this. In my website, I would like the user to input text into a single or multiple textbox(es) and then have the contents of the textbox(es) stored to either a variable or an array. Then I would like to have that variable/array compared to other arrays. Basically, the user is searching for items in a database. The user can search for as many or as little items as they want. Then the item(s) will be compared to multiple arrays to find out if what the user wants is in the database. So for example, let's say the user is searching for recipes that have all or part of these ingredients: chicken, broccoli, lemon, honey. So, there would have been a total of 4 textboxes...one for each ingredient. These ingredients are stored to an array..lets call it ingredient(). In the database of recipes, each recipe has its own array which includes the ingredients needed to make the recipe, we'll call them tag1(), tag2(), and tag3(). Now, I want the array, ingredient(), to be compared to each of the "tag" arrays to see if any of the "tag" arrays include exactly match the ingredient() tag in part or in whole. Is this possible? Hey guys, I'm hoping this is possible or that there is an easier way to do this. I'm having an issue with displaying data from one array that contains information about users in a table that is controlled by a different array. Is it possible to do this or is this use of arrays to display the data the wrong approach? The table is located on one webpage, I simply want to extract one piece of information that I have placed in the initial array as part of the login script that contains user information (for validation for login etc) and display it in a table on the new webpage that is opened as a result of successful validation of the user details. I'm completely stumped and after many attempts I just can't seem to get it to work. Hi, Here is a working code to copy 2d php array to 2d javascript array. Code: <html> <head> <?php for($i = 0; $i < 3; $i++) { for($j = 0; $j < 2; $j++) {$quest[$i][$j] = $i*10+$j;} } ?> <script type="text/javascript"> var questions = new Array(3); for (var i = 0; i < 3; i++) { questions[i] = new Array(2); } questions[0] = ["<?php echo join("\", \"", $quest[0]); ?>"]; questions[1] = ["<?php echo join("\", \"", $quest[1]); ?>"]; questions[2] = ["<?php echo join("\", \"", $quest[2]); ?>"]; document.write(questions[0][0] + "<br />"); document.write(questions[0][1] + "<br />"); document.write(questions[1][0] + "<br />"); document.write(questions[1][1] + "<br />"); document.write(questions[2][0] + "<br />"); document.write(questions[2][1] + "<br />"); </script> </head> </html> Now,here's the thing.Notice these lines in the code questions[0] = ["<?php echo join("\", \"", $quest[0]); ?>"]; questions[1] = ["<?php echo join("\", \"", $quest[1]); ?>"]; questions[2] = ["<?php echo join("\", \"", $quest[2]); ?>"]; I would like to put these lines in a loop,something like for (var i = 0; i < 3; i++) { questions[i] = ["<?php echo join("\", \"", $quest[i]); ?>"]; } But even after a lot of efforts I am unable to do so,what am I doing wrong?Thanks |