I posted this in the VBScript forum but got nowhere, managed to write something that works in javascript, but now I have another issue.
We have an application that prompts the user for an input using
A request came in to replace the text input box with a drop down list. I knew i couldn't do this with a regular Modal Box so I put the functionality into a pop-up. The user selects a reason from the drop down and that value is passed back to the opening window and the script takes over from there.
Here's where it gets tricky...
The page is written with over 1000 lines of vbscript (client side) and the prompt is called as follows:
What I've done is created a javascript function that opens a window, takes the value that was entered and passes it back to a hidden text field on the original window and strReason reads from this text field.
The VBScript
The JavaScript
So, my issue is with the wait() function - which is basically a pause function I picked up of the web...that recursion is causing the script to timeout on some of our older machines and I need a way to stop executing the script in the background until that pop up window is closed (which is what a standard model box does). The rescusion is required so that the vbScript does not continue.
The other thing is that there are about 28 different reasons that need to be collected so the pop up will appear 28 times (once for each reason).
I've put what I have so far (in a pick-a-month) example where you are prompted to pick three months and once you are complete, the three months will display. You can see that here:
Anyone have any ideas? Is is possible to create a custom modal box that works the same way as a prompt(), alert() or confirm()???? Although it would be great if someone gave me code to get started, it would also be great if someone can help me find a good tutorial on how to do this - I've been looking but can't seem to find anything.
Unfortunatley, re-writing it is not an option, but dropping the project might be. There are 1000's of lines (no kidding) of vbScript written and although we are in the process of re-visiting this one page and potentially re-writing it, we're a few months away from even getting started. If it is possible to do what I need, it will have to be incorporated into what we have and we can do it better if/when we get to the full re-write.
Thanks...
TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
We have an application that prompts the user for an input using
Code:
strReason = prompt('enter reason');
A request came in to replace the text input box with a drop down list. I knew i couldn't do this with a regular Modal Box so I put the functionality into a pop-up. The user selects a reason from the drop down and that value is passed back to the opening window and the script takes over from there.
Here's where it gets tricky...
The page is written with over 1000 lines of vbscript (client side) and the prompt is called as follows:
Code:
do while strReason = ""
strReason = InputBox("enter reason")
if strReason = "" then
msgBox("You must enter a reason")
end if
loop
...do something with strReason
What I've done is created a javascript function that opens a window, takes the value that was entered and passes it back to a hidden text field on the original window and strReason reads from this text field.
The VBScript
Code:
winNew = openWin() ' this is a javascript function
strReason = tbxSelValue.value
The JavaScript
Code:
//global
var winRef;
var isOpen;
function openWin() {
winRef = window.open("selectReason.html","selWindow","toolbar=no,width=250...");
isOpen = true;
for (var i = 0 ; isOpen ; i++)
isWindowOpen()
return true;
}
function isWindowOpen() {
if (!winRef.closed) {
wait(100);
isOpen = true;
} else {
isOpen = false;
}
}
function wait(msecs)
{
try {
var start = new Date().getTime();
var cur = start
while(cur - start < msecs)
{
cur = new Date().getTime();
}
} catch (e) { return true; }
}
So, my issue is with the wait() function - which is basically a pause function I picked up of the web...that recursion is causing the script to timeout on some of our older machines and I need a way to stop executing the script in the background until that pop up window is closed (which is what a standard model box does). The rescusion is required so that the vbScript does not continue.
The other thing is that there are about 28 different reasons that need to be collected so the pop up will appear 28 times (once for each reason).
I've put what I have so far (in a pick-a-month) example where you are prompted to pick three months and once you are complete, the three months will display. You can see that here:
Anyone have any ideas? Is is possible to create a custom modal box that works the same way as a prompt(), alert() or confirm()???? Although it would be great if someone gave me code to get started, it would also be great if someone can help me find a good tutorial on how to do this - I've been looking but can't seem to find anything.
Unfortunatley, re-writing it is not an option, but dropping the project might be. There are 1000's of lines (no kidding) of vbScript written and although we are in the process of re-visiting this one page and potentially re-writing it, we're a few months away from even getting started. If it is possible to do what I need, it will have to be incorporated into what we have and we can do it better if/when we get to the full re-write.
Thanks...
TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers