1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

xml/xls toggle data with radio button

Discussion in 'HTML, Graphics & Programming' started by Adam, 3 May 2006.

  1. Adam

    Sgarrista

    Joined: 18 Oct 2002

    Posts: 8,950

    xml/xls toggle data with radio button (new question added)

    Hi,

    Im looking for some help. I have 2 sets of data, one called "train" one called "plane". I also have corresponding radio buttons relating to each of these 2 options. I am trying to figure out how I can toggle between each set of data when the relavent radio button is selected. For example, when the train radio button is selected the train data will be shown whereas the plane data will be hidden.

    Can't find anything through google which may help me achieve this, I really don't know where to start :confused:

    Thanks,

    Adam
     
    Last edited: 4 May 2006
  2. joilet

    Wise Guy

    Joined: 25 Dec 2002

    Posts: 1,540

    Location: South GLOUCESTER

    I think the page will need to be reloaded to do the XSL transformation with the new XML data - be that in the browser or server side.

    If i had to do this, i would be doing it server side and when transformation takes place; depending on a query request, it would use different sets of XML data. I would still use the same XSL as id just make one large template.

    mypage.asp?view=train
    mypage.asp?view=plane

    depending on the query, a variable would be set with a path to the XML sheet for that data.

    As for the radio buttons controlling it, you can use javascript to refresh the page with the query different for each option. Or you can post the data to the page and the server side code will act on it.

    I don't know how to do this with just XML and XSL though, although i think its possible to incorporate server side scripting into these documents as long as you make sure the web server parses the file type and you specify the scripting in the page itself.
     
  3. Adam

    Sgarrista

    Joined: 18 Oct 2002

    Posts: 8,950

    Thanks for your help, although I should have specified that I cannot use any server side code. I might give up on this for now and try it solely with javascript as its turning into a nightmare.
     
  4. Adam

    Sgarrista

    Joined: 18 Oct 2002

    Posts: 8,950

    Ok, I am still having problems.

    I need a page which I can select between two different types of data (as per my train and plane example above). I have managed to get this working in javascript. I also need to be able to sort the order of the data that then appears (sort fields such as price or the ID of the plane/train) which I have followed another example which explains how to do it using XSLT.

    Is it possible to combine the both? Im struggling to see how, my javascript example works, but its as if the data is appearing on a new page. I can't then add any extra buttons or form elements to be able to sort the data as per how I want to sort this. Similarly, I can't find a way using XSLT to filter the different plane/train data in my XML file but I have the code working to sort the data.

    So, to summarise. Im allowing the user to make a choice to display data relating to a train or a plane. When this data appears following the users choice, I want to display some form elements such as a button to be able to sort the data by the ID of the train/plane or by price.

    Can anyone help please?
     
  5. joilet

    Wise Guy

    Joined: 25 Dec 2002

    Posts: 1,540

    Location: South GLOUCESTER

  6. Adam

    Sgarrista

    Joined: 18 Oct 2002

    Posts: 8,950

    Unfortunatly I wasn't able to work out a solution from that website, thanks anyway.

    Ok heres what I have so far.

    Function for the button:

    Code:
    function returntransport()
    	{
    	var nodes, selection
    	selection = document.transporttype.go.value
    	if (selection == 0)
    	alert("Transport selection")
    	else if (selection == 1)
    	nodes = declaration.documentElement.selectNodes('/transport/train')
    	else if (selection == 2)
    	nodes = declaration.documentElement.selectNodes('/transport/plane')
    My buttons:

    <form name="transporttype">

    <input type="button" name="go" value="train" onclick="returntransport()"/>
    <input type="button" name="go" value="plane" onclick="returntransport()"/>

    </form>