Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


why does it write in a new window?

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,52332
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> why does it write in a new window?
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 why does it write in a new window? - 9/29/2007 7:12:46 AM   
  Tin

 

Posts: 15
Score: 0
Joined: 8/30/2007
Status: offline
I cannot figure out why when I call the sub view_onclick, it opens in a new window?
I have re-written this many times in different ways.
can some one explain what I am missing here.
thanks,
Tin

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<title>Test</title>
<script language="vbscript">
Sub window_onload
     PopSecDropDown
End Sub

sub view_onclick
dim a, b 
set a = window.document.getElementById("select1")
set b = window.document.getElementById("select2")
       Dim strPrefxone : strPrefxone = a.options(a.selectedindex).text
    Dim strPrefxtwo : strPrefxtwo = b.options(b.selectedindex).text
  
window.document.write("<br />" & strPrefxone & "<br />" & strPrefxtwo)
end sub
  
  Sub PopSecDropDown
      document.getElementById("select2").innerHTML = ""
      Dim objSel1 : Set objSel1 = document.getElementById("select1")
    
      Dim strPrefx : strPrefx = objSel1.options(objSel1.selectedindex).text
    
 dim objOption
 dim i
 dim bb(2)
 bb(0) = "a"
 bb(1) = "b"
 bb(2) = "c"   
 select case strPrefx
 
 case "A"
 for i = 0 to 2 
 Set objOption = document.createElement("option") 
 objOption.text = bb(i)
 document.getElementById("select2").add(objOption)
 next
    
 case "B"
 Set objOption = document.createElement("option")
 objOption.text = "My"   
 document.getElementById("select2").add(objOption)
 case "C"
 Set objOption = document.createElement("option")
 objOption.text = "Name"
 document.getElementById("select2").add(objOption)
 case "D"
 Set objOption = document.createElement("option")
 objOption.text = "Is"
 document.getElementById("select2").add(objOption)
 end select     
 
  End Sub 
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>some text here</p>
<p>&nbsp; </p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>

</p>
<form name="input_form" id="input_form">
<select id="select1" onchange="PopSecDropDown">
   <option>A</option>
   <option>B</option>
   <option>C</option>
</select>
&nbsp;&nbsp;
<select id="select2">
</select>
<input type="button" value="view" name="view">
</form>

</body>
</html>
 
 
Post #: 1
 
 RE: why does it write in a new window? - 9/30/2007 2:14:10 PM   
  TNO


Posts: 1400
Score: 16
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
What browser are you using? in IE7 its staying in the same window. This sounds like a browser setting. Tools-->Internet Options-->Tab Settings

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to Tin)
 
 
Post #: 2
 
 RE: why does it write in a new window? - 10/1/2007 4:23:18 AM   
  Tin

 

Posts: 15
Score: 0
Joined: 8/30/2007
Status: offline
Thanks TNO
I'm using IE6, I'll look at the settings.
For clarification, I suppose it's not a new window as in a second window pops up.
as soon as I click the "view" button the results of the selection from the drop down ( window.document.write("<br />" & strPrefxone & "<br />" & strPrefxtwo) )are displayed on a blank page and the drop down's are gone.

thanks,
Tin

(in reply to TNO)
 
 
Post #: 3
 
 RE: why does it write in a new window? - 10/7/2007 11:47:35 AM   
  Tin

 

Posts: 15
Score: 0
Joined: 8/30/2007
Status: offline
I'm back with no success.
onclick of the view button, the drop downs disappear and the document.write statement writes on a blank white page.
I do not know why, it's very frustrating.
Can anyone shed some light on this for me please.
Thanks,
Tin.

(in reply to Tin)
 
 
Post #: 4
 
 RE: why does it write in a new window? - 10/7/2007 3:30:12 PM   
  TNO


Posts: 1400
Score: 16
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
window.document.write("<br />" & strPrefxone & "<br />" & strPrefxtwo)

change that portion to something like this:

document.getElementById("some Element").innerHTML("<br />" & strPrefxone & "<br />" & strPrefxtwo)

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to Tin)
 
 
Post #: 5
 
 RE: why does it write in a new window? - 10/8/2007 7:04:31 AM   
  Tin

 

Posts: 15
Score: 0
Joined: 8/30/2007
Status: offline
Thanks again TNO
I googled innerhtml and figured out how I can use that for what I was trying to achieve.
Although I do not understand why the document.write wiped my page clean and then wrote the 2 variables I have trying to display.

Why wouldn't the document.write statement simply just write the 2 variables under the dropdowns instead of wiping the page clean and then writing the variables.

Thanks.
Tin

(in reply to TNO)
 
 
Post #: 6
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> why does it write in a new window? Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts