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

External JS file submitting form

Status
Not open for further replies.

lbrooks

IS-IT--Management
Jan 20, 2004
42
0
0
US
I have the following written:

With an XSLT file:

I calling a function to submit the form:

<form method="post" name="newrecipe">

...other code

<input type="button" onClick="javascript:CreateNewRecipe(this.form,document.getElementById('productname').value, document.getElementById('proddesc').value, '{$CopiedRecipe}')" value="Create Recipe" class="BtnFlat" style="cursor: hand;"/>
...
</form>

I have a function in external JS file like so:

function CreateNewRecipe(newrecipe, prodname, proddesc, CopiedRecipe) {
var sActionValue ="NewRecipe.asp?prodname=" + prodname + "&proddesc=" + proddesc + "&copiedrecipe=" + CopiedRecipe;
newrecipe.action=sActionValue;
newrecipe.submit();

}

The problem I am having it that when it launches the NewRecipe.asp is launches it as an file, so in the browser I see:
file://mes/dsr/Dev/NewRecipe.asp?prodname=adsa&proddesc=asas&copiedrecipe=My%20Product

Instead of \\mes\\dsr\NewRecipe.asp?prodname=adsa&proddesc=asas&copiedrecipe=My%20Product

Which would not run the ASP file being called since it thinks it is being called like a file. What would cause this or better question how do I fix this. I could just be overlooking something. Any help would be appreaciated it.



 
Are you running this through IIS or some other web server that processes ASP scripts? Are you mixing JSP and ASP scripting on one server?

Lee
 
Then what is

'{$CopiedRecipe}'

? It looks like some kind of server-side scripting, but isn't ASP.

Lee
 
If the contents of '{$CopiedRecipe}' has a single or double quote in it on the client side, it will cause problems with calling the Javascript function in the onclick event handler (which does NOT need the keyword javascript: included to call the function).

Lee
 
{$CopiedRecipe} is a parameter value in XSLT.
 
It shows the value that I am expecting. But I have figure out what my problem is. For reference the problem is the fact the the default language for ASP is vbscript and I was calling javascript code within ASP. Thanks anyway.
 
You can't call client-side functions from server-side code. You didn't show that part of your code, though.

Lee
 
I called server side code from client side code, which you can do.
 
Only if you're using AJAX. That's the only way the client-side can work with server-side scripting. You need to show the code you're working with if you want any further help.

Lee
 
I already said i solved the problem. And what you say is not true, you can call ASP(server side code) from a client form. I mean if you don't know, then you don't know but to futhur make up things well, there is a lot to be said there. Let's end it, I have solved my problem and thanks for your help.
 
Look I didn't mean to be so sharp. I really appreaciate your effort and you taking the time to help.
 
I'm very interested to hear (and I'm sure trollacious is as well) how you invoke a server side function from a client side call. There are 2 very common and documented ways - submitting the form/page and using AJAX (which is basically another way to submit information).

Since you stated above (quite fervently I might add...) that "And what you say is not true, you can call ASP(server side code) from a client form" then surely you will have some sort of example to back up your claims (and subtle mud-slinging).

Please, enlighten us.

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
you can call ASP(server side code) from a client form.

Well, I've been an MVP in the ASP forums for years now and I've never seen this happen so I'm very interested in seeing it also.

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
I mis-spoke. All I meant was that I can invoke ASP code by submitting a form. My point was that Ajax was not the only means. I should not have replied to trollacious so harshly, as they were only trying to help.
 
I have another question. I did get this to work via a Windows 2000 server, but I get the same problem on a Windows 2003 machine. A recap of the issue describes differently:

When submitting a form the browser displays the following for the page being called:

file://mes/dsr/Dev/NewRecipe.asp?prodname=adsa&proddesc=asas&copiedrecipe=My%20Product

Instead of

\\mes\\dsr\NewRecipe.asp?prodname=adsa&proddesc=asas&copiedrecipe=My%20Product

Any Ideas to why this would happen. Do you need more information/code from me.

Thanks.
 
That typically happens when you're viewing the file locally and not through a web server. Make sure you use a URL that processes the page through the web server and isn't from just clicking on the page to run it in the browser locally.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top