Here is what I currently have for one of my menus which gives the user the opportunity to search for a loan number from a menu:
with(milonic=new menuname("Loan Search")){
style=menuStyle;
aI("text=<FORM METHOD=GET ACTION=/mypage/loan_info.asp target=_blank name=loansearch><table><tr><td><B><FONT COLOR=339966 SIZE=2>Enter Loan # </FONT></B></td></tr><tr><td><input name=loan size=11></td></tr><tr><td><input type=submit value=Search></td></tr></table></form>;type=form;align=center");
}
What I want to do is be able to open the new page in a new browser session as a dialog style (similar to annoying popup adds). Here is the code I use to do this:
<A HREF="javascript:void(0)" onclick="javascript:window.open('http://www.mypage.com','newWindow', 'width=400, height=400, resizable');">click me</a>
How can I take this second piece of code and implement it into the menu code I already have so that when a search is done through my menu it opens up this new page in dialog style?
Thanks
Running Javascript inside a <FORM> tag for menu link
-
- Beginner
- Posts: 4
- Joined: Mon Sep 15, 2003 5:50 pm
You really dont need a form, just alittle javascript. Now take this with a grain of salt because I am currently at my university and can't test this but if you cant get it to work, I will make it work at home and give you it.
Your menu item should look like follows: (notice the ID field of the input, its important and also, its not a submit button, just a regular button that we assign a onclick event to.
Then in the head of your document, have a javascript function that takes the value in the textbox and sends it to a query page, in a popup.
And then in your new pop up page, you need to grab the variable out of the URL using either standard server side language (ASP, PHP, etc) or the equivalent HTTP handlers for it. If you dont know how to do that, do a search on google for parsing a url query string. Once you can grab it out of the URL, you can pass it to whatever search algorithm you have. Hope this works, I threw it together in just a couple minutes. 
Your menu item should look like follows: (notice the ID field of the input, its important and also, its not a submit button, just a regular button that we assign a onclick event to.
Code: Select all
with(milonic=new menuname("Loan Search")){
style=menuStyle;
aI("text=<B>Enter Loan # </B><BR><input name='loan' id='loan' size=11><input type=button onclick='submitQuery();' value=Search>;align=center");
}
Code: Select all
<SCRIPT>
function submitQuery()
{
//this document.all[] works in IE, you may have to find the equivalent for NS
queryStr = document.all["loan"].value;
window.open("http://www.mypage.com?q=" + queryStr,"newWindow", "width=400, height=400, resizable");
}
</SCRIPT>

Dave Hergert
Software Engineer
"Helping to make the menu better, one
at a time."
Software Engineer
"Helping to make the menu better, one

-
- Beginner
- Posts: 4
- Joined: Mon Sep 15, 2003 5:50 pm
-
- Beginner
- Posts: 4
- Joined: Mon Sep 15, 2003 5:50 pm
Aww man, and I thought I was spot on! Ahh well, theres still room for improvement. haha
Ok to center it, use this as your new pop up function....I've tested it and it works perfect in IE6. BTW, this will put the popup in the center of the SCREEN, not the browser. So no matter where the browser is, the popup will be smack dab in the center.
ALways glad I can help.
Ok to center it, use this as your new pop up function....I've tested it and it works perfect in IE6. BTW, this will put the popup in the center of the SCREEN, not the browser. So no matter where the browser is, the popup will be smack dab in the center.
Code: Select all
function centeredPopup(URL,popupHeight, popupWidth)
{
var screenH = screen.height;
var screenW = screen.width;
var fromLeft = parseInt((screenW-popupWidth)/2);
var fromTop = parseInt((screenH-popupHeight)/2);
//this document.all[] works in IE, you may have to find the equivalent for NS
var queryStr = document.all["loan"].value;
window.open(URL + "?q=" + queryStr,"newWindow", "width="+popupWidth+", height="+popupHeight+",left="+fromLeft+",top="+fromTop+" resizable");
}
Dave Hergert
Software Engineer
"Helping to make the menu better, one
at a time."
Software Engineer
"Helping to make the menu better, one
