This is want I want to do:
I have links (just underlined text with link and target specified) on
a navigation bar inside a frame, and a checkbox. If the text box is
clicked the new page is displayed in a new browser window, if not in
the central frame.
The problem is that I cannot get the status of the checkbox without
submitting the form. Clicking the links don't submit the form. It
seems I have to change the links into submit buttons, but I'd prefer
not to do that.
What is the sensible way of doing this? The links could call a page
that determines whether the checkbox is selected or not and the call
the right page accordingly.
I am using Windows 2000 and IIS.
Ideas, recommendations, and examples appreciated.
Many thanks.
A link to your page would be helpful!
I think a short javascript would help, where you test the checkbox status
when clicking on your link.
But I think you can get better solvings with the link posted.
-sebp-
Sorry not possible yet.
>
> I think a short javascript would help, where you test the checkbox
status
> when clicking on your link.
How?
Is there an onclick event that on clicking the checkbox a script could
run to set a variable in the server?
Alternatively, as you suggest how can one get a script to run on
clicking a link and how is the status checked. The document object,
perhaps?
Thanks for taking the time to reply.
<html>
<head>
<script>
function Function(){
if (eval("document.formbox.group.checked") == true){
document.location="http://www.yoursite.com"}
if (eval("document.formbox.group.checked") == false){
window.open("http://www.yoursite.com");}
}
</script>
</head>
<body>
<form name="formbox">
<input type = "radio" name="group">
<a href onClick=Function()> LINK </a>
</form>
</head>
</html>
Good luck with it,
greetings
Ang Talunin
> I think this will work...it works with me....:-)
>
> <html>
>
> <head>
>
> <script>
> function Function(){
> if (eval("document.formbox.group.checked") == true){
> document.location="http://www.yoursite.com"}
> if (eval("document.formbox.group.checked") == false){
> window.open("http://www.yoursite.com");}
>
> }
> </script>
>
> </head>
>
> <body>
>
> <form name="formbox">
> <input type = "radio" name="group">
// works of course also with "checkbox"
> <a href onClick=Function()> LINK </a>
>
> </form>
>
> </head>
// to fast...has to be </body>, it works anyway, but just for the right
script
> I have links (just underlined text with link and target specified) on
> a navigation bar inside a frame, and a checkbox. If the text box is
> clicked the new page is displayed in a new browser window, if not in
> the central frame.
You could peek at Mikodocs (great resource on HTML &Co., by the way) to
see how they do it:
http://www.idocs.com/tags/quicklist.html
It has some extra complications, since it tries to preserve the user's
selection via cookies. But the basic logic is to have some JavaScript
code executed so that a form containing a checkbox is generated - it
would clearly be misleading to have a checkbox when JavaScript is off -
and set variable when the user checks the checkbox. And the links on the
page then have onclick="if(...) newwin(this)" where the condition tests
for that variable.
That particular code is for letting the user check a box if he wants all
links to open in a new window. If you'd like to make it open links in the
full window, then the onclick code should be modified so that it
conditionally opens a page (naturally, the same as in href) in the
desired way and performs return false to prevent normal link processing.
Followups trimmed. Hint: The average usefulness of a thread is inversely
proportional to the cube of the number of groups it is posted to.
(Korpela's 42nd law.)
--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
What are the other 41? (I couldn't find them on your site)
Cheers, Donald
--
http://www.drnoble.co.uk donaldrnoble at yahoo dot com
--
http://www.AccessibleComputers.co.uk
Hardware, Software & Custom built PC Systems
Thank you all.
I have tried something along these lines and works fine to set the
NewWindow session variable when I click the checkbox.
A new problem is that I am getting a "Object required" error for the
line "window open" :
when I click on a link
<A href="dispatch.asp?customers.htm" target=mainFrame>Customers</a>
And in dispatch.asp:
<% @Language=VBScript>
<%
page = Request.QueryString
if session("NewWindow") = "True" then
window.open page
else
response.redirect page
end if
%>
Why?
Many thanks
"Ang Talunin" <psych...@hotmail.com> wrote in message
news:a3mrtk$303e$1...@news.kabelfoon.nl...
tiglath <tig...@usa.net> schreef in berichtnieuws
a3oroj$5em$1...@bob.news.rcn.net...
I want to open a page on its own window or in the main frame depending
on whether a check box in the navigation bar is checked or not. Why
this doesn't work?
Any ideas?
Many thanks
-----
<html>
<head>
<SCRIPT>
function dispatch(page) {
if (document.form1.checkbox.checked)
window.open(page);
else
document.location=page;
}
</SCRIPT>
</head>
<body>
<a href='#' onclick="dispatch("+""""+
"customers.htm"+""""+")">Customers</a>
<form name="form1">
<INPUT type=checkbox name="checkbox">
</form>
</body>
</html>
>> Followups trimmed. Hint: The average usefulness of a thread is
>> inversely proportional to the cube of the number of groups it is
>> posted to. (Korpela's 42nd law.)
>
> What are the other 41? (I couldn't find them on your site)
Wait a minute... I do have them somewhere... oh yes:
http://www.cs.tut.fi/~jkorpela/usenet/laws.html
ObDHTML: If you're using IE with JScript enabled, don't click on
anything on that page.
--
Yucca, http://www.cs.tut.fi/~jkorpela/
// What are you trying to do wiht this?
You can NEVER use " like this. If you, you first open with the first " and
close it directly with the second ". So instead of " you should at least use
'.
Ang Talunin
---
<html>
<head>
<SCRIPT>
function dispatch(page) {
if (eval("document.form1.checkbox.checked")== true)
window.open(page);
else
document.location=page;
}
</SCRIPT>
</head>
<body>
<form name="form1">
<INPUT type=checkbox name="checkbox">
<a href onClick=dispatch("http://www.altavista.com")>Customers</a>
// or you can use your own url, as long as it is complete, wiht http://
etc...
</form>
</body>
</html>
Thank you very much for taking the time.
I have made it work with a combination of single and double quotes and
without the eval():
function dispatch(page) {
if (document.form1.checkbox.checked)
window.open(page);
else
document.location=page;
}
and for the link
<a href ='#' onclick='dispatch("customers.htm")'>Customers</a>
It works now.
Much obliged too all.
"Ang Talunin" <psych...@hotmail.com> wrote in message
news:a3rvja$2gjs$1...@news.kabelfoon.nl...