Click to See Complete Forum and Search --> : javascript to detect changes in xsl/t elements


XMLNewbie
05-01-2003, 01:46 PM
Hi!

I am trying to write a javascript that will look at the textboxes I have on a table generated by XSL. When a user makes a change to any of textboxes and presses the submit button. I would like the changed data to be emailed to a predetermined address.

<SCRIPT>
function form_onsubmit(){
var pstrXML = new String();
// Create the new XML string
pstrXML+= '<email>\n';
pstrXML+= '<subject>' + {contact_name} + </subject>\n';
pstrXML+= '<subject>' + {contact_phone1} + </subject>\n';
pstrXML+= '<subject>' + {contact_phone2} + </subject>\n';
pstrXML+= '</email>';
// Set the string to the hidden input box
form.hiddeninput.value = pstrXML;
// Submit the form
form.submit();
}
</SCRIPT>

<FORM name="form" onsubmit="form_onsubmit();" ACTION="send.asp"
METHOD="POST">
<input type="hidden" id="hiddeninput" value=""></input>
<INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Only Press Once to Send
Changes" />
</FORM>

Any ideas what I am missing?

khalidali63
05-01-2003, 02:49 PM
the correct syntax for these 2 lines
form.hiddeninput.value = pstrXML;
// Submit the form
form.submit();

is this

document.form.hiddeninput.value = pstrXML;
// Submit the form
document.form.submit();

XMLNewbie
05-01-2003, 03:19 PM
Hi!

Thank you for the correction.

Is my form code perhaps wrong? Because I am getting an email generated when the submit button is clicked but no data is being sent.

Thank you in advance.

khalidali63
05-01-2003, 03:43 PM
few errors needed attention

here use this

<SCRIPT>
function form_onsubmit(){
var pstrXML = new String();
// Create the new XML string
pstrXML+= '<email>\n';
pstrXML+= '<subject>' + (contact_name) + '</subject>\n';
pstrXML+= '<subject>' + (contact_phone1) + '</subject>\n';
pstrXML+= '<subject>' + (contact_phone2) + '</subject>\n';
pstrXML+= '</email>';
// Set the string to the hidden input box
document.form1.hiddeninput.value = pstrXML;
// Submit the form
document.form1.submit();

<FORM name="form1" onsubmit="form_onsubmit();" ACTION="send.asp"
METHOD="POST">
<input type="hidden" id="hiddeninput" value=""></input>
<INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Only Press Once to Send
Changes" />
</FORM>

}
</SCRIPT>

XMLNewbie
05-01-2003, 04:07 PM
Hi Khalid:

I tried the suggested changes. No submit button is displayed on the table. I think it is because the form code is in the javascript. So I tried it outside the javascript and I still do not get any data in the email. Should the javascript above the </xsl:template> statement or above the </tr> statement ?

Thank for your help.