|
-
Dec 21st, 2004, 11:15 AM
#1
Thread Starter
Junior Member
html variable help
I have the following html code:
</SCRIPT>
<script language="JavaScript">
<!--
function OpenAbout()
{
var centerWidth=(screen.width/2)-(680/2);
var centerHeight=(screen.height/2)-(600/2);
var sReportName = "about.aspx"
winpops=window.open
(sReportName,"_blank","height=600,width=680,top="+centerHeight+",left="+centerWidth+",toolbar=0,loca tion=0,directories=0,status=0,scrollbars=0,menubar=0,resizable=0,")
}
//-->
</script>
Can I change the line:
var sReportName = "about.aspx"
so that "about.aspx" is equal to the text of a combo box on the web page?
-
Dec 21st, 2004, 12:41 PM
#2
Hyperactive Member
Re: html variable help
the first parameter of the window.open command is the URL for the page
so yes you can do what you like with it
edit:
and I have just realised you are asking how to change the line, I'll make summat up for you, 5 mins
Last edited by tailz; Dec 21st, 2004 at 12:45 PM.
-
Dec 21st, 2004, 12:53 PM
#3
Hyperactive Member
Re: html variable help
Modified the javascript slightly and there is a dropdownlist in there somewhere.
HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>TailzCombo</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="JavaScript">
<!--
function OpenPopup(sReportName)
{
var centerWidth=(screen.width/2)-(680/2);
var centerHeight=(screen.height/2)-(600/2);
winpops=window.open(sReportName,"_blank","height=600,width=680,top="+centerHeight+",left="+centerWidth+",toolbar=0,location=0,directories=0,status=0,scrollbars=0,menubar=0,resizable=0,")
}
//-->
</script>
</HEAD>
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<asp:DropDownList id="DropDownList1" runat="server" onchange="javascript:OpenPopup(this.value)">
<asp:ListItem Value="http://www.vbforums.co.uk/" Selected="True">vbforums</asp:ListItem>
<asp:ListItem Value="http://www.PosterCash.co.uk/">PosterCash :]</asp:ListItem>
</asp:DropDownList></TD>
</form>
</body>
</HTML>
-
Dec 22nd, 2004, 02:44 AM
#4
Thread Starter
Junior Member
Re: html variable help
what do I type instead of:
var sReportName = "about.aspx"
what do i replace the "about.aspx" with.
my combo box is populated from a database can i reference the text property??
-
Dec 22nd, 2004, 04:07 AM
#5
Hyperactive Member
Re: html variable help
Have you even tried that code I pasted?
It references the .Value property of the selected item in the combobox.
-
Dec 23rd, 2004, 04:03 AM
#6
Thread Starter
Junior Member
Re: html variable help
Thanks
Sorry for not seeing that.
I would like to however only open the window if a (panel for example) is visible on the screen.
can i set a varible in the HTML script to equal a variable from the vb code.
i.e.
var bselected= "var in vb code"
-
Dec 23rd, 2004, 04:11 AM
#7
Hyperactive Member
Re: html variable help
You can inject javascript but I think you can also do this;
HTML Code:
<script language="JavaScript">
<!--
function OpenPopup(sReportName)
{
var sReportName=<% =FunctionInVB()%>
var centerWidth=(screen.width/2)-(680/2);
var centerHeight=(screen.height/2)-(600/2);
winpops=window.open(sReportName,"_blank","height=600,width=680,top="+centerHeight+",left="+centerWidth+",toolbar=0,location=0,directories=0,status=0,scrollbars=0,menubar=0,resizable=0,")
}
//-->
</script>
then just create
VB Code:
Function FunctionInVB() As String
Return "about.aspx"
End Function
Don't believe thats the neatest way to do it. you should look at "injecting" javascript into your code
-
Dec 23rd, 2004, 06:23 AM
#8
Thread Starter
Junior Member
Re: html variable help
Think I'm getting somewhere (thanks for the help).
One last problem (I hope)
I have the following function
function OpenReport()
{
var centerWidth=(screen.width/2)-(680/2);
var centerHeight=(screen.height/2)-(600/2);
var sReportName = <% =GetTargetPage()%>
var machinecount= <% =GetMachineCount()%>
if (machinecount != 0)
{
winpops=window.open
(sReportName,"_blank","height=600,width=680,top="+centerHeight+",left="+centerWidth+",toolbar=0,loca tion=0,directories=0,status=0,scrollbars=0,menubar=0,resizable=0,");
}
}
My problem is that sReportName equals:
'../Reports/MachineStatus.aspx?StartDateTime=23/12/2004 05:45:00& EndDateTime=23/12/2004 17:45:00?MachineType='Filler14, Filler13'&MachineCount=2'
(when I pass it from the vb script I have to add ' to the beginning and wnd for it to work)
This errors due to the extra ' on the machine type. Is there a way round this?
Thanks
-
Dec 23rd, 2004, 06:32 AM
#9
Thread Starter
Junior Member
Re: html variable help
Just ommitted the ' .
Works
Thanks for all your help. really appreciate it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|