Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is it possible to return input from custom dialog window

Status
Not open for further replies.

sleenh

Programmer
Sep 11, 2003
1
US
Apart from using 'prompt' is it possible to create a custom dialog that will return input to the originating javascript? If it is, any suggestions?

Thanks for any help...
 
You could do the same thing with a small pop-window that you could fully customize.

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
You have 2 options... (as I see it)

Option #1

Use a div that is hidden and then display it when you need it... it can be absolutly positioned on the page so it will in affect hover over your page... Since it is on the same page (document) it is easy to retrieve the info and then hide the div again...

Problems with option 1
This method will not work with netscape...
The positioning can get tricky if the page could be scrolled to various positions...
If you have underlying Select lists they will not "hide" behind your pop-up div automatically... you would have to manually hide them...

Option #2
Pop a new window and size it smaller... then on an event write the values back to the parent window.

window.open(URL, windowName[, windowFeatures])
see...

If you need to reuse the popup... like if it is a datepicker you can put the parent form #, and object name to set in a querry string and then dynamically write the save function... (see example below)

example
--------------------------
file # 1 (main.htm)
--------------------------

<html>
<head>
<script>

var win;
var nll;

function kill(){
if (!win==nll &&!win.closed()) win.close();
}

function getStuff(){


kill();

win = window.open(&quot;popup.htm&quot;,&quot;popup&quot;,&quot;width=350, height=350 &quot;);
win.focus();

}
</script>
</head>
<body>
<form name='frm'>

<input type='text' name='stuff'> <input type='button' value='click me to go to popup' onclick='getStuff()'>
</form>
</body>
</html>

--------------------------
file # 2 (popup.htm)
--------------------------
<html>
<head>
<script>


function save(){
//var dt;
//var cl = document.all.cal

//dt = cl.month + &quot;/&quot; + cl.day + &quot;/&quot; + cl.year
//opener.document.forms[0].ef_tvarchar_tDate_sRec.value=dt;
// for required fields make not red if filled in or red if not...
//if(opener.document.forms[0].ef_tvarchar_tDate_sRec.ValidationType){
// opener.fixMyStyle(opener.document.forms[0].ef_tvarchar_tDate_sRec);
//}
opener.document.forms[0].stuff.value = document.frm.stuff.value;
opener.focus();
window.close();


}

</script>
</head>
<body>
<form name='frm'>

<input type='text' name='stuff'> <input type='button' value='click me to put text on main page' onclick='save()'>
</form>
</body>
</html>
 
Whoops... in my haste I forgot to remove the actual code I copied the example from.. so ignore the commented out code...

//var dt;
//var cl = document.all.cal

//dt = cl.month + &quot;/&quot; + cl.day + &quot;/&quot; + cl.year
//opener.document.forms[0].ef_tvarchar_tDate_sRec.value=dt;
// for required fields make not red if filled in or red if not...
//if(opener.document.forms[0].ef_tvarchar_tDate_sRec.ValidationType){
// opener.fixMyStyle(opener.document.forms[0].ef_tvarchar_tDate_sRec);
//}
 
Would something like this do it for you: faq216-3388

Cheers,


[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top