Click to See Complete Forum and Search --> : retain value in a XML form


Yan Cui
September 27th, 2000, 04:58 PM
I wrote an ASP program, which using XML DOM to generate a XML document and a prefined XSL is used to transform it into HTML page. The XSL adds a search form to the document. The problem is once the search form (contains textbox, selection list, radio button) is submited and user click the back button on a browser, the browser can not retain the value user entered. Is there anyone know How to retain values in the form?

al_paso
September 28th, 2000, 04:51 PM
From what I understand once the XML is converted (transformed) into HTML into the it appears as a simple HTML page and I see no reason why it should not retain the values (except if you have a password field) when you click the Back button. Do you want to populate the from with the values the user has already entered and there has been an error that you want to alert the user about?

Yan Cui
September 28th, 2000, 08:03 PM
I do want to populate the form with previous entered value. I test it with IE 5, the browser just show a form with no value.

By the way, do you know how to do the client side form validation with XML?

al_paso
September 29th, 2000, 01:04 PM
There are two ways:
1) Do it in the XSL file with tags
Here you can define your JavaScript/VbScript functions like this:

function doSomething(){
return "Hello World";
}

Then execute this function anywhere on the page:
doSomething()
Or even do some validation and then attach to event handler of any control:

function doSomeValidation(){
if(document.frmTest.txtEmail.value == ""){
alert("Please enter Email address");
}
}


doSomeValidation()
This will create an onclick handler for a given HTML element for which you need validation.

2) If you are doing the XSL transformation in an asp /HTML page then define the validation routines in that page itself. When the HTML is generated the functions will refer to the HTML elements correctly:
For e.g lets say xyz.asp is your page where the transformation happens:


Routine that transforms XML to HTML using XSL()


Hope that helps..

Yan Cui
September 29th, 2000, 05:27 PM
Thanks a lot. Another question, I don't know how to use the XSL to set the selected attribute of a selection list or the checed attribute of a group of radio button. I use:


1
for the selection list. However, it didn't work as expected.

al_paso
September 29th, 2000, 08:10 PM
Again..all this is easier and cleaner to do in the ASP or HTML page after the HTML has been transformed.
Based on the value write a function that sets the selected property to true:
function toggleSelection(){
if(document.frmSomeForm.txtSomeControl.value == 1){
document.frmSomeForm.chkSomeCheckBox.selected == true;
}
}