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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I reference VBScript variables in Javascript??

Status
Not open for further replies.

allyeric

Programmer
Mar 14, 2000
104
CA
I am using VBScript to create my ASP pages. But, I need to use a javascript function (confirm) to send user to another page. But, I need to send the value of a VBScript variable to the next page also. Is there any way this can be done?

Here is my confirm:

function jsConfirm() {
if (confirm("Are you sure you want to cancel this RFQ?")) {
location=("newrfq7.asp?button=cancel")
}
}


Can I send a vbscript variable through the same querystring?

Thanks for any help.

Ally
 
Try something a little different.

function jsConfirm() {
var ans = confirm("Are you sure you want to cancel this RFQ?");
return ans;
}

<Form ..... action=..... onSubmit=&quot;return jsConfirm();&quot;>

......

</FORM>

The information on this page will be submitted only if the return value from the javascript function is true. If the return value is false, nothing will happen. This makes it simple to use vbscript to pass querystring values and other information to the page requested. (The true or false values are the values returned from the confirm dialog box; OK = true, CANCEL=false) Have fun!
 
use a hidden tag to send the value of the VBscript variable:
<form>
<input type='hidden' name='Myvar' value='<%=VBScriptVariable%>'>
</form>


nick bulka

 
Thank you both for your replies. Nick, I did have it in a hidden field, just didn't know how to get it into the querystring. But, I did get it to work, sent the form to the JS function, then referenced that variable on the form.


function jsConfirm(form) {
var RFQ = form.RFQ.value
if (confirm(&quot;Are you sure you want to cancel this RFQ?&quot;)) {
location=&quot;newrfq7.asp?button=cancel&RFQ=&quot; + RFQ
}
}


....

<input type=&quot;hidden&quot; name=&quot;RFQ&quot; value=<%=RFQID%>>

<input type=&quot;button&quot; name=&quot;Cancel&quot; value=&quot;Cancel&quot; onClick=&quot;jsConfirm(this.form)&quot;><br></td>



Thanks again for your help.

Ally
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top