homerUK
12-21-2002, 12:30 PM
hi,
I have one main page called "index.htm" -- this has a Javascript file called "functions.js". There are buttons on the index page which popup different windows depending on which button you press.
I have a function called "isForm" which detects if there is a valid "form" tag within the page. In this function, I need to set a variable which can be passed on to the popup window....... here's the code:
function isForm()
{
if (iView.document.selection.type == "Control")
{
//the user must be selecting to MODIFY the form element, so open the window for modifying
alert("you want to modify it");
return true;
}
else
{
//there is a form, so carry on to see if the user has placed the cursor INSIDE the form tags
iView.focus();
var cursorPos = iView.document.selection.createRange();
var elt = cursorPos.parentElement();
if (elt.tagName == "FORM") {
return true;
} else {
alert("You are not inside the form, or there is no form found");
return false;
}
}
}
that checks if the cursor is inside the form tag..... then I use the following code to open the popup window...
function formTextfield()
{
if (isForm()) {
imageWin = window.open('editor/files/form_textfield.htm','','width=500,height=300,scrollbars=yes,resizable=yes,titlebar=1');
}
}
so that function uses "isForm" to check if it's a form, and opens the popup depending on if it is in the form or not.
but in the code above I do a check to see if the user has selected a Control element... this is because if they have already inserted a form field, they must be wanting to edit it.
I thought I could just do
var todo = "modify";
then in the popup window use
if (window.opener.todo == "modify")
//start the modify code
but it doesnt get the "todo" value.
Any ideas??
thanks..!!
I have one main page called "index.htm" -- this has a Javascript file called "functions.js". There are buttons on the index page which popup different windows depending on which button you press.
I have a function called "isForm" which detects if there is a valid "form" tag within the page. In this function, I need to set a variable which can be passed on to the popup window....... here's the code:
function isForm()
{
if (iView.document.selection.type == "Control")
{
//the user must be selecting to MODIFY the form element, so open the window for modifying
alert("you want to modify it");
return true;
}
else
{
//there is a form, so carry on to see if the user has placed the cursor INSIDE the form tags
iView.focus();
var cursorPos = iView.document.selection.createRange();
var elt = cursorPos.parentElement();
if (elt.tagName == "FORM") {
return true;
} else {
alert("You are not inside the form, or there is no form found");
return false;
}
}
}
that checks if the cursor is inside the form tag..... then I use the following code to open the popup window...
function formTextfield()
{
if (isForm()) {
imageWin = window.open('editor/files/form_textfield.htm','','width=500,height=300,scrollbars=yes,resizable=yes,titlebar=1');
}
}
so that function uses "isForm" to check if it's a form, and opens the popup depending on if it is in the form or not.
but in the code above I do a check to see if the user has selected a Control element... this is because if they have already inserted a form field, they must be wanting to edit it.
I thought I could just do
var todo = "modify";
then in the popup window use
if (window.opener.todo == "modify")
//start the modify code
but it doesnt get the "todo" value.
Any ideas??
thanks..!!