Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass variable to vbscript

Status
Not open for further replies.

huobaji

Technical User
Sep 20, 2010
23
US
I am trying to pass a variable to a vbscript function
using a button in my form. For some reason its not working for me. Can someone help me?

i appreciate any help
thanks

<script language="vbscript">

function send(filename2)

Value = MsgBox ("You deleted the file...",4,"You deleted the file.")
If Value = 6 Then
MsgBox filename2
Else
MsgBox "You pushed No!"
End If

end function

</script>



'VARIABLE SET
<%
filename2 = "testing"
%>


'HTML
<form id="form4" name="form3" method="post" onclick="send filename2" action="">
<input type="submit" name="Submit2" value="YES" class="style3" />
</form></td>

 
[tt]<form id="form4" name="form3" method="post" onclick="send ""<%= filename2 %>""" action="">[/tt]

Cannot even guarantee it does any good. For instance, the onclick thing should probably be positioned in the submit button; and even if it is positioned correctly, you have to provide a returnvalue to stop submitting the form, etc etc...

The whole construction is so defective and lack of clarity, no wonder you do not get "helpful helps" sofar in asp forum and others: saying thanks when you received no advice (which does not help your cause), and unable to response to clarify your problem or saying thanks when you received some...
 
amendment
This nesting of quote should be corrected (my post above is wrong in html, sorry about that).

[tt]<form id="form4" name="form3" method="post" onclick="send [highlight]'[/highlight]<%= filename2 %>[highlight]'[/highlight]" action="">[/tt]
 
Is there a way to push the variable to another page

the variable is not part of the form

I tried this

<form id="form4" name="form3" method="post" action="another_page.asp '<%filename%>'">
 
[1] If you want to pass, as suggested rightly or wrongly by the line posted above, server-side variable filename via client and then pass to another page, you can do this: supposing f is the query string name.
[tt]
<form id="form4" name="form3" method="post" action="another_page.asp[blue]?f=<%= escape(filename) %>[/blue]">
[/tt]
[1.1] It would then be kind of hybrid, using post method but with parameter f passed as what get method would do. Also, in that case, the value of filename would be in the clear in the url, if you do not mind.

[1.2] Without encoding (such as escape() in the above), in most case, it is inacceptable and is a sure receipe for trouble.

[2] The way to preserve the uniformity of using post method and avoiding filename being expose in the clear in the url, is to construct a hidden input type, with name f, say like in [1], which will be used in the server-side script to capture the value passed.
[tt]
<input type="hidden" name="f" value="<%= replace(filename, """", "&#x22;") %>" />
[/tt]
[2.1] This approach should be better if post method is already the method to use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top