Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 167
  • Last Modified:

Show XML as webpage

Hello Experts!

I've searched the entire Internet looking for an answer to this question and am hoping that someone here can help me figure out how to do this:

I want to create a webpage with a form that has just a few fields. Those fields would be "location", "size", and "gender". Once somebody enters one or all of the values in this form and presses Submit, I would like a URL passed to an XSLT page (which is an XML source) containing the values that were selected.

So, for instance, someone selects Austin,TX as their location, size as Small, and gender as female from the form. When they click submit, the URL that I then want referenced in my XSLT page that would then open would be
http://www.mydomain.com/pet.find?key=12345&sex=F&location=austin,tx&size=small.


Can ANYONE tell me how to do this?? Thank you in advance!!!
0
ambientsbs
Asked:
ambientsbs
  • 2
  • 2
1 Solution
 
Tom BeckCommented:
I'm thinking you would want users to select sex and size from dropdowns or checkboxes. With javascript you could redirect with something like this:

<script type="text/javascript">

var sexObj = document.getElementById('sexOption');
var selIndex = sexObj.selectedIndex;
var locText = documentGetElementById("locTextbox").value;
var sizeObj = document.GetElementById('sizeOption');
var sizeIndex = sizeObj.selectedIndex;

function onSubmit() {
    window.location = "http://www.domain.com/pet.find?key=12345&sex=" + sexObj.options[selIndex].value + "&location=" + locText + "&size=" + sizeObj.options[sizeIndex].value;
}

</script>
0
 
ambientsbsAuthor Commented:
Thanks for the feedback! I definitely agree that the sex and size should be dropdowns and would create them like that.

So from what I'm reading, clicking the I would be setting up the form so that once someone clicks "submit" they would be redirected to the www.domain.com/pet.find?....?

That leads me to 2 questions:

1. I would want to REQUIRE that someone enter a location, but the size and sex aren't necessary. Would this javascript work correctly in the case that they were to leave those other fields blank?

2. Using this method, how do I tie my xml stylesheet to the www.domain.com/pet.find?..... page?

Thank you so much !
0
 
Tom BeckCommented:
1. You should provide a default selected index that would yeild an empty string so if the user does not make a selection, the javascript will still work. Better still, you could check to see if a value has been entered first before splicing together the redirect url. If nothing was selected, shorten the query string to just the queries(s) you have values for.

2. I'm assuming you have some kind of server side script that parses the query string for the selections made and returns a result based on those selections. For example, your pet.find could in reality be pet.php. When pet.php is requested via the redirect (with query included), some php script would run on the server side that is able to extract a subset of the XML based on the query string and return the results back to the client. I suppose you could do it all with client side scripting but you would have to expose the entire XML file to the client for every request.
0
 
ambientsbsAuthor Commented:
Thanks for the feedback and sorry for the delayed reply.

Makes sense about your first thought, but I do have an issue with the 2nd. The URL that I'm generating, www.domain.com/pet.find?..., with the variables from the form I'm creating, is not pulling from a server that I have control over. So, it doesn't seem as if I'd be able to setup a server-side script for this.

What I would like to do is have somebody click the "Submit" button on the form and redirect to a page on MY server that then references the URL created above and an XML stylesheet that turns that data into something that looks nice. Any suggestions on how to do this?
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now