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

How to access server side script inside a javascript function?

Status
Not open for further replies.

Kendel

Programmer
Apr 24, 2002
1,512
0
0
US
Hi,

Is it posible to access serverside script inside a javascript function? If so, how?

Thanks.
 
Kinda? Do you have any example of what your trying to do?
 
I want to call a serverside function inside a javascript something like:

Code:
<script language="javascript">
<!--
function setSubmit(){
        <%=Save(intID, intHID, 0, 1)%> 
	submitted = true;
 	return true;
}
-->
</script>

Thanks
 
I've used sever-side to diclared the function and values passed int he those funtions inside javascript. But, thats taking place before the page is being sent to the client. I don't think the client can call back to the server. (Sounds like a big security risk for Db information) Sorry I wasn't more help.
 
No, client-side script cannot call server-side script functions. Ever.

Server-side script is processed and completed before the client computer ever sees the page. The only way to "call" a server-side function using client-side scripting would be to browse to another page.

*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
One way to do what you're doing is to maybe open a small popup window with the function. The popup window could be a PHP or ASP file that will do your server-side scripting for you, then the window could close.



*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
This is from msdn:

Code:
<HTML>
<HEAD>
<TITLE>Popup Example</TITLE>

<SCRIPT LANGUAGE="JScript">
var oPopup = window.createPopup();
function ButtonClick()
{
    var oPopBody = oPopup.document.body;
    oPopBody.style.backgroundColor = "lightyellow";
    oPopBody.style.border = "solid black 1px";
    oPopBody.innerHTML = "Click outside <B>popup</B> to close.";
    oPopup.show(100, 100, 180, 25, document.body);
}
</SCRIPT>
</HEAD>

<BODY>
<BUTTON onclick="ButtonClick()">Click Me!</BUTTON>
</BODY>
</HTML>

Now, I want to replace:

oPopBody.innerHTML = "Click outside <B>popup</B> to close.";

With an ASP form so that I can save the info to database. Like: oPopBody.innerHTML = <%=MySaveFunction()%>

OR:
oPopBody.innerHTML = "<form .....>blab blab"</form>
When I try to submit the form, nothing happen.


Just don't ask me why I don't use window.open :)

Any help would greatly appreciated!
 
Thank you for all your helps. I don't think that is possible.
 
I found the following code on a website that calls another page and updates a database without redirecting/reloading the page.

Code:
var newImg = new Image();
newImg.src = '?action=add&item_id=' + item_id;

The code is part of a funtion that is called when an image is clicked on.

Has anyone used this technique before or has more info about it?

Rich
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top