473,385 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Custom Dialogue

107 100+
Hi,

I've made a class to show various forms to the screen. The only thing I cant figure out is how to integrate it so they return a value like normal dialogues..

You will see better from an example.

Here is a simplified version of the class i made:


Expand|Select|Wrap|Line Numbers
  1.     function Form(type){        
  2.  
  3.         switch (type){
  4.             case 0:
  5.                 width = "450";
  6.                 height = "300";
  7.  
  8.                 newDiv = document.createElement("div");
  9.                 newDiv.className = "form";    
  10.                 newDiv.style.left = (window.innerWidth/2) - (width/2) +"px";
  11.                 newDiv.style.top = (window.innerHeight/2) - (height/2) +"px";
  12.                 newDiv.style.width = width + "px";
  13.                 newDiv.style.height = height + "px";
  14.                 newDiv.appendChild(this.makeButtons("OkCancel"));
  15.                 this.object = newDiv;
  16.  
  17.             break;
  18.  
  19.         }
  20.  
  21.         document.body.appendChild(this.object);
  22.  
  23.  
  24.     }
  25.  
  26.     Form.prototype.makeButtons = function(type){
  27.  
  28.         var buttons = document.createElement("div");
  29.         var me = this;
  30.  
  31.         switch (type){
  32.             case "OkCancel":  //ok & cancel
  33.  
  34.  
  35.                 newButton = document.createElement("input");
  36.                 newButton.type = "button";
  37.                 newButton.value = "Cancel"
  38.                 newButton.onclick = function(){me.setResponse(false);}
  39.  
  40.                 buttons.appendChild(newButton);
  41.                 newButton = document.createElement("input");
  42.                 newButton.type = "button";
  43.                 newButton.value = "OK"
  44.                 newButton.onclick = function(){me.setResponse(true);}
  45.                 buttons.appendChild(newButton);
  46.                 break;
  47.  
  48.             default:
  49.  
  50.  
  51.         }
  52.  
  53.         return buttons;
  54.  
  55.     }
  56.  
  57.     Form.prototype.setResponse = function(response){
  58.         this.response = response;
  59.  
  60.         this.remove();
  61.  
  62.     }
  63.  
  64.     Form.prototype.remove = function(){
  65.         document.body.removeChild(this.object);
  66.     }
  67.  

and then its run from the page with something like....

Expand|Select|Wrap|Line Numbers
  1. function showform(){
  2.  
  3.     response = new Form(0);
  4.  
  5.     alert(response);
  6.  
  7.  
  8. }
  9.  

but obviously there is something missing, I need it to wait until the user has clicked a button before returning...

Can anyone help??


Thanks!


Andy
Apr 23 '08 #1
1 958
pronerd
392 Expert 256MB
I need it to wait until the user has clicked a button before returning...
You can trigger your logic to be called on an onClick event.

Expand|Select|Wrap|Line Numbers
  1. <div onClick="callYourFunctionHere()" >Click Here</div
Apr 23 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Raymond H. | last post by:
Hello, I tried the line in vb but it open the dialogue box (I'd like not to open this box; I'd like save without viewing a dialogue box). WebBrowser1.ExecWB OLECMDID_SAVEAS,...
2
by: kevinm3574 | last post by:
So, I'm doing the following in a php script so that I can fire a download dialogue AND redirect the page (after clicking submit in a form). I'm doing it this way because of the problem with...
5
by: kevin | last post by:
Hi, Any help with this would be really appreciated! I'm trying to download a file from a remote server. The access permissions is okay but the problem I'm facing is that the file is getting...
5
by: Brett Porter | last post by:
Hi, A very large portion of my site uses forms authentication which seems to work reasonably well. However many of my authenticated pages display a basic authentication dialogue box prior to...
12
by: Ger | last post by:
My dialogue form (sometimes partly, sometimes as a whole) remains visible during a fairly long processing job. The dialogue asks the user to enter some data for the job to follow, and after OK,...
44
by: sasan3 | last post by:
Please read below for my collective response to recent posts on this topic. First a repeat of my suggestion: "Anytime you feel you are in a position to answer a question, but don't feel like...
3
by: UltimateNickFury | last post by:
Hello, I am trying to display the "Printer Settings" dialogue in vb.net. I have found the code for performing this in VB6 but am wondering how this is done in vb.net. Thanks.
0
by: ld | last post by:
Hi, I have a lib that implements the custom actions for my setup. I would like to be able to interupt the setup if an error occured or if the user wants to cancel one of the forms that execute...
12
by: Donn Ingle | last post by:
Hi, Okay, so I am in the mood to try this: Inform the user about what modules the app requires in a graphical dialogue that can vary depending on what the system already has installed. (It will...
9
by: Gord | last post by:
In VB6, a custom dialog can be easily created by adding a new form, adding whatever controls you like, sizing it as you like, adding code and then just loading/unloading it whenever you like....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.