The challenge - I've been called out...

college_amy

Regular
Joined
Jan 3, 2004
Messages
83
Ok I have been challenged by a guy here at work. Here is the challenge:
He has a page that does stuff when a button is clicked. He wants to have a pop up window come up in the middle of the code that a user can verify or change the data in it and then send it back to the page and continue the code. Would look kinda like this:
Code
Code Code Code

popupwindow()
STOP CODE UNTIL RESPONSE RECEIVED FROM popupwindow()
Get data from popupwindow()
put new values into existing process and continue code

code code code
code

Follow? My question is: How do you do this in RUNTIME?
He said there is no way to do this anywhere - I don't believe him which Is why he challenged me to find a way.

So I call on the great geniuses of Xtreme.net talk to give their input - oh high ones... :)
Amy

BTW - he doesn't want postback but all one seamless process..... OH - I can do it in a panel and not pass it to another page...
 
Last edited:
oops. . . I forgot, you cant right-clcik "view source" on a modal window. . .

here's the code for 'default.htm'
PHP:
<html>
<script>
function editValues()
{
 var invals = new Object();
 invals.value1 = document.all.value1.innerHTML;
 invals.value2 = document.all.value2.innerHTML;
 var vals = window.showModalDialog("./editVals.htm", invals,
   " dialogHeight: 200px;  dialogWidth:300px; dialogTop: px; dialogLeft: px; " +
   "center: Yes; edge: Raised; help: Yes; resizable: No; status: No; scroll:no;");
 if (vals != null)
 {
  document.all.value1.innerHTML = vals.value1;
  document.all.value2.innerHTML = vals.value2;
 }
}
</script>
<body>
<span ID="value1">foo</SPAN>
<br> 
<span ID="value2">foo</SPAN>
<br>
<button onclick='editValues();'>Edit</button>
</BODY>
</HTML>
here's the code for 'editvals.htm':
PHP:
<html>
<script>

function returnVals(cancel)
{
 if (cancel) return null;
 var outvals = new Object();  
 outvals.value1 = document.all.value1.value;
 outvals.value2 = document.all.value2.value;
 window.returnValue = outvals;
 window.close();
}

function loadArgs()
{
document.all.value1.value = window.dialogArguments.value1;
document.all.value2.value = window.dialogArguments.value2;
}
</script>
<body onload='loadArgs();'>
<table>
<TR><TD>Value 1:</TD><TD>
<input ID="value1" type="text" /></TD></TR>
<TR><TD>Value 2:</TD><TD>
<input  ID="value2" type="text" /></TD></TR>
</table>
<br>
<button ID="ok" onclick='returnVals(false);'>Ok</button>
<button ID="cancel" onclick='returnVals(true);'>Cancel</button>
</body>
</html>
 
Will using a modal dialog box stop the processing code in its tracks until it retrieves the values back from the box?

Basically on the parent form a user inputs data... then they click submit - it then begins to go through the data and when it reaches a certain data element it stops - pops up the dialog box for verification of the data and if a change is need the user can change it at that time if it is all good, then the user presses ok in the child dialog box and it goes back to the parent form puts in the new values (if there is new values) and continues on processing the data.

So is that what this is doing?
Amy :)
 
Any time you launch a modal object (form, box, whatever) from the parent object, the parent object will wait for a response from the modal object before continuing.
 
college_amy said:
Will using a modal dialog box stop the processing code in its tracks until it retrieves the values back from the box?

Basically on the parent form a user inputs data... then they click submit - it then begins to go through the data and when it reaches a certain data element it stops - pops up the dialog box for verification of the data and if a change is need the user can change it at that time if it is all good, then the user presses ok in the child dialog box and it goes back to the parent form puts in the new values (if there is new values) and continues on processing the data.

So is that what this is doing?
Amy :)
yes. . .

now, this isnt a submit button. . .

if you want the submit to do the check, then you need to attach to the form's onsubmit event. If onsubmit return's false, the form is not submitted. . . that being said you would do something like:
PHP:
 <html>
<script>
function editValues()
{
var invals = new Object();
invals.value1 = document.all.value1.innerHTML;
invals.value2 = document.all.value2.innerHTML;
var vals = window.showModalDialog("./editVals.htm", invals,
   " dialogHeight: 200px;  dialogWidth:300px; dialogTop: px; dialogLeft: px; " +
   "center: Yes; edge: Raised; help: Yes; resizable: No; status: No; scroll:no;");
if (vals == null) return false;
document.all.value1.innerHTML = vals.value1;
document.all.value2.innerHTML = vals.value2;
return true;
}
</script>
<body>
<form onsubmit='editValues();'>
<span ID="value1">foo</SPAN>
<br> 
<span ID="value2">foo</SPAN>
<br>
<input type="submit"/>
</form>
</BODY>
</HTML>
 
I wonder if she means some sort of processing that is happening on the server. If that's the case I imagine she could post via RPC which would handle the validation she mentioned. Wish I had time to write an example but I'm pretty new to RPC still and haven't done a heck of a lot.

But yeah, 'it can't be done' isn't part of my vocabulary either; it's 'how much are you willing to pay me' that determines whether it will or won't be done. :)
 
Really I think it boils down to what the problem is as to which solution is best..if any. A rethink of the way the app works may in the end be the ultimate solution!
 
Back
Top