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.



 
Yes you are right. But this page is the result of a user clicking submit. On Win 2000 server it works fine, but on Win 2003 is does not work.

So on my form I have a button like so(keep in mind that this form is created within an XSLT file):
<input type="button" onClick="CreateNewRecipe(this.form,document.getElementById('productname').value, document.getElementById('proddesc').value, '{$CopiedRecipe}')" value="Create Recipe" class="BtnFlat" style="cursor: hand;"/>
...
</form>


Which is calling this external JS function:

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

}

Any ideas? Strange that the two different servers respond differently. And Thanks again.
 
What's the URL of the page that's being submitted?

Your problem isn't at all strange, and is exactly what I'd expect if the page wasn't being processed through a web server, like I've stated twice before.

Lee
 
Like I've stated, it needs to go through the web server to process the ASP and submit correctly. The backslashes (\\) are a good sign that it's not. The URL should be something like

localhost/mes/dsr/Dev/RecipeMain.asp

or

127.0.0.1/mes/dsr/Dev/RecipeMain.asp

Lee


 
Ok. I think this may cause the problem, but I don't know why. Let me start from the beginning. I have a page RecipeMain.asp. RecipeMain.asp is like a container for all other page.

So within the RecipeMain.asp I have the following:
<td>
<DIV id="folderTree" STYLE="padding-top: 8px;"></DIV>
</td>
<td valign="top">
<!-- Folder Tree Container -->
<DIV id="folderTreeDetail" STYLE="padding-top: 8px;"></DIV>
</td>


When the user Clicks "New Recipe" from a menu item(defined in RecipeMain, but I do not show), that calls the NewRecipe function in my external JS that looks like the following:

function NewRecipe(NewRecipeName, RecipeDesc, CopiedRecipe) {
var sNewRecipe


var objXSLT
var objXML
var objXSL
var objXSLTProc
objXML = new ActiveXObject('MSXML2.DOMDocument.4.0');
objXSL = new ActiveXObject('MSXML2.FreeThreadedDOMDocument.4.0');
objXSLT = new ActiveXObject('MSXML2.XSLTemplate.4.0');


// Set the property to valid the file when its parsed.

// objXML.validateOnParse = true;
// objXSL.validateOnParse = true;
objXSL.async = false;
objXML.async = false;



objXSL.load("tree/newrecipe.xsl")


objXSLT.stylesheet = objXSL

objXML.load("tree/test.xml")

objXSLTProc = objXSLT.createProcessor()
objXSLTProc.input = objXML
objXSLTProc.addParameter("ProductName", NewRecipeName)
objXSLTProc.addParameter("ProductDesc", RecipeDesc)
objXSLTProc.addParameter("CopiedRecipe", CopiedRecipe)
objXSLTProc.transform();
// alert(sParam1 + "_" + sParam2)


folderTree.innerHTML = objXSLTProc.output;
folderTreeDetail.innerHTML = "";

}


The newrecipe.xsl looks like so:


<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="
<xsl:param name="ProductName"/>
<xsl:param name="ProductDesc"/>
<xsl:param name="CopiedRecipe"/>


<xsl:template match="//BatchInformation">



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


<table><tr><td colspan="2" CLASS="styHeader">New Recipe<br/></td></tr>
<tr><td class="stySubItem1" colspan="2"> * denotes required field <br/></td></tr>
<tr><td class="stySubItem1">*Enter Product Name</td><td><input type="text" class="FormL" name="productname"/></td></tr>
<tr><td class="stySubItem1">*Enter Product Description</td><td><input type="text" class="FormL" name="proddesc"/></td></tr>
<tr><td class="stySubItem1">Copy Recipe</td><td>
<input type="text" class="FormL" name="copiedrecipe" disabled="true" value="{$CopiedRecipe}"/>
<input type="button" class="BtnFlat" value="Browse" onClick="Javascript:CopyRecipe()"/></td></tr>
<tr><td class="stySubItem1" colspan="2" align="right"><br/><input type="button" onClick="CreateNewRecipe(this.form,document.getElementById('productname').value, document.getElementById('proddesc').value, '{$CopiedRecipe}')" value="Create Recipe" class="BtnFlat" style="cursor: hand;"/></td></tr>
</table>

</form>
</xsl:template>

...
</xsl:stylesheet>


Do you see where I am going? I don't understand why the above would be a problem.
 
I am not running this on my local machine. It is on another machine.
 
Ok beat me over the head. My bad. I get what you are saying. But I did learn something else. It appears that on a Win 2003 box it only recognizes the .aspx extention. Is this true?
 
No

[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]
 
Ok. I have figured it out. Thanks to trollacious. for some reason I could not see the most simplest thing. Arghhh. But thanks so much.
 
trollacious, I know how frustrating it can be when you have someone on the other end missing the obvious. My apologies again for my rudeness last week. And I really appreacite your help this week. I am not that bad, just my head in the clouds the past week. Until next time. If you need a vote or something send them my way.
 
If you need a vote or something send them my way.

Actually, you could send one his way by clicking the "thank trollacious for this valuable post". Receiving stars for the help given on TT is always a nice little bonus [smile]

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
Since I don't see a purple thing anywhere near trollacious name I will do it for you.

Christiaan Baes
Belgium

"My new site" - Me
 
I was able to "thank trollacious for this valuable post". There are purple links next to his name on every reply. Did misunderstand something?
 
they are there because chrissie placed them there. after you click the "thank ... for this valuable post" link, a popup window should appear with a confirmation link. once you click THAT link, the person gets a star.



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top