J.D. Deutschendorf

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromJ.D. Deutschendorf
ToMe
Subjectform submit method for calling xmlimporting script
Date4 August 2004 15:12
Mark,

I loved your xmlimport script! One question though, i'd like to call
the script by using a form submit button and passing in a value to the
query string of the URL using HTTP GET. This is instead of clicking on
the hyperlink as shown in your example. I'm NOT a javascript guru like
yourself, and am having (predictably) some problems in getting this to
work. Any suggestions?

J.D.
FromMe
ToJ.D. Deutschendorf
SubjectRe: form submit method for calling xmlimporting script
Date4 August 2004 19:53
J.D.

this is actually fairly easy, since all forms do is construct a URL anyway,
you can use script methods to construct it manually

function getXML(oForm,oFunc) {
 for(var x=0,elem,oStr='';elem=oForm.elements[x];x++){
  if(elem.name) {
   oStr += oStr ? '&' : '?';
   oStr += escape(elem.name) + '=' + escape(elem.value);
  }
 }
 importXML( oForm.action+oStr, oFunc );
}
...
<form action="blah.php" onsubmit="getXML(this,'runThis');return false;">
...
<input type="submit" value="go">
</form>

(not actually tested this, hope it works)

Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromJ.D. Deutschendorf
ToMe
SubjectRe: form submit method for calling xmlimporting script
Date4 August 2004 22:47
Mark,

Thanks for the quick response! I'm still having problems though...
I've put an html page out there with your original code and a function
I wrote. It's at:

http://xxx.xxxxxx.xxx/xmltest.html

I can't get this file to work on my server, but when I run it from my
local machine the hyperlink runs fine, but I can't get the form
submission to do the same thing.

Any help you might be able to shed on this would be appreciated.

Thanks!

J.D.
FromMe
ToJ.D. Deutschendorf
SubjectRe: form submit method for calling xmlimporting script
Date5 August 2004 09:14
Attachmenta php script to serve remote XML files locally
J.D.

simple mistake, you have put quotes areound your string. no need to do that.
it is already a string. remove the single quotes

var xmlURL = "http://blah.someAddress.com/etc/blah?someid=" + strNewSS;

as a secondary point, you are trying to load a file from another server.
several browsers will be unhappy about this. if at all possible, you should
use a server-side-script to read the XML file and pass it through your own
server.

I have attached a php script that should do it

Tarquin
FromJ.D. Deutschendorf
ToMe
SubjectRe: form submit method for calling xmlimporting script
Date5 August 2004 16:29
Mark,

Thanks for your help! I'm bummed about javascript's same-origin policy
preventing client-side access. I wanted to see if this could be done
completely on the client.

I guess that if the XML could be output as javascript and referenced
within a SCRIPT tag, then my problem would be solved, as I understand
the same-origin policy doesn't apply to that tag.

Oh well...

Thanks Again!

J.D.
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.