Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Passing Values of open Dialogue Box in Textbox

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Passing Values of open Dialogue Box in Textbox
  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 >>
 Passing Values of open Dialogue Box in Textbox - 5/26/2005 1:55:01 AM   
  kya_karey

 

Posts: 39
Score: 0
Joined: 5/11/2005
From: India
Status: offline
Hi ,
i would like to write the name of the file in the same textbox called "templatefile"
i am using this but it writes the name of the file in another text box and in new page.

Would you please tell me where is the mistake

<html>
<br></br>
<br></br>
<head><h1>Template Patcher</h1></head>
<style type="text/css">
h1 {text-align: center}
</style>
<br></br>
<br></br>

<body>
<div align="center">
Template Name:     <input type="text" size="40" name="templatefile"></input>
<br></br>
<br></br>
<h2><input type="button" name="okTemplate" value=" OK " align="middle" onclick="return CallScript();"></input>      
<input type="button" name="OpenTemplate" value=" Cancel " align="middle"></input>      
<input type="button" name="BrowseTemplate" value="Browse" align="middle" onclick="return OpenTemplate();"></input></h2>
</div>
</body>

<script type="text/vbscript">
Function OpenTemplate()
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "XML Document xml|*.xml|All Files|*.*"
objDialog.FilterIndex = 1
objDialog.InitialDir = "C:\Scripts"
intResult = objDialog.ShowOpen
If intResult <> 0 Then
//Wscript.Echo objDialog.FileName
Document.write ("<input value=" & objDialog.FileName & "></input>")
End If
End Function


Function CallScript()

End Function
</script>
</html>
 
 
Post #: 1
 
 Re: Passing Values of open Dialogue Box in Textbox - 5/26/2005 2:40:21 AM   
  Zifter


Posts: 318
Score: 0
Joined: 1/5/2005
From: Belgium
Status: offline
Like I've been saying before:
document.write will replace the content of your page

...please reread your posts (Display 2 tables in one HTML page , How to overwrite table)
and check MSDN

(in reply to kya_karey)
 
 
Post #: 2
 
 Re: Passing Values of open Dialogue Box in Textbox - 5/26/2005 3:08:19 AM   
  kya_karey

 

Posts: 39
Score: 0
Joined: 5/11/2005
From: India
Status: offline
Hello ,
i think u didnt understand me clearly;

I would like to display the file name is the textbox called "templatefile" if i do what u suggest me

then it will display the name of the file in same html page but write the name of the file in another textbox.

U see what i want to do is Want to select the file from open Dialoge box and wrote it into the given textbox.

(in reply to kya_karey)
 
 
Post #: 3
 
 Re: Passing Values of open Dialogue Box in Textbox - 5/26/2005 6:35:48 PM   
  Zifter


Posts: 318
Score: 0
Joined: 1/5/2005
From: Belgium
Status: offline
I think you don't understand me clearly.
quote:
document.write will replace the content of your page

In other words, the textbox "templatefile" and the buttons you have on your page are first removed and then replaced with what you write and that is a textbox without a name.

If you want the selected filename in your "templatefile", you'll have to use the "value" property of that textbox.
Something in the lines of "document.all.templatefile.value = objDialog.FileName"

(in reply to kya_karey)
 
 
Post #: 4
 
 Re: Passing Values of open Dialogue Box in Textbox - 5/26/2005 7:26:13 PM   
  kya_karey

 

Posts: 39
Score: 0
Joined: 5/11/2005
From: India
Status: offline
Thanks Zifter,

It's working but it returns whole path in the textbox.
I just want to write the file name like "abc_xyz.xml"

Not like "C:/Scripts/abc_xyz.xml".

Would you please tell what should i do ??
Should I need to split the string and take the name of file ??

(in reply to kya_karey)
 
 
Post #: 5
 
 Re: Passing Values of open Dialogue Box in Textbox - 5/26/2005 7:51:43 PM   
  Zifter


Posts: 318
Score: 0
Joined: 1/5/2005
From: Belgium
Status: offline
You could use the Split() function to get only the filename part. But you don't know how many subfolders the selected file will be in, so you don't know which element of the array you will have to take.
I would suggest to use a combination of the Mid() function (= take a part of a string) and the InstrRev() function (= find the position of a certain substring in a string starting from the end).
Example:
      HTH

(in reply to kya_karey)
 
 
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 >> Passing Values of open Dialogue Box in Textbox 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