If value in name field in top row disable submit button until add button is pressed or field is clea

C

Chuck

Hi!

I have a table that was created with xslt.
It has a blank row at the top with an add button to the far right.

Is there a way to detect if someone has entered a value in the "name"
field only on the top row then the submit button will be disabled
until the add button is pressed (which causes the contents of the top
row to be moved to the bottom of the table and clears the top row
(this all works) or there is no longer a value in the name field on
the top row. So long as there is a value in the top row's name field
the submit button must be disabled.

I have rows below the first row that will have values in the name
field. It must check just the first row's name field.

The reason for all of this is several users have filled out the top
row and then submitted the form without pressing the add button so the
new information was never sent.

My attempt at the javascript is below. I am new to javascript so
please be kind.

Any constructive suggestions would be greatly appreciated.

Chuck

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="https://www.xyz.com/mynamespace">

<xsl:eek:utput method="html" version="4.0"/>

<xsl:template match="/contactlist">
<script language="javascript">
var doSubmit = false;
function verifyAddSubmit()
{
var nameField = document.getElementsById("name");
if(nameField[0].Value != "")
{
doSubmit = true;
document.form1.submit();
}
}
</script>
<table style="font-size: 10pt" width="100%" border="1"
bordercolor="#418181" cellpadding="2" cellspacing="0">
<tr style="background-color:#CBCCDA">
<th>Order</th>
<th>Name</th>
<th>Phone 1</th>
<th>Phone 2</th>
<th>Add/Delete</th>
</tr>
<!--
Creates row of blank fields for adding records
-->
<tr>
<xsl:attribute name="bgcolor"><xsl:choose><xsl:when test="position()
mod 2 = 1">#F0F1F5</xsl:when><xsl:eek:therwise>#E0DFE3</xsl:eek:therwise></xsl:choose></xsl:attribute>
<td align="center">
<INPUT maxLength="2" name="order" size="2" value=""/>
</td>
<td align="center">
<INPUT maxLength="30" name="name" size="28" value=""/>
</td>
<td align="center">
<INPUT maxLength="30" name="priphone" size="28" value=""/>
</td>
<td align="center">
<INPUT maxLength="30" name="altphone" size="28" value=""/>
</td>
<td align="center">
<INPUT type="button" name="add" value="Add">
<xsl:attribute name="onclick"><![CDATA[ if((document.form1.order.value
== '') ||
(document.form1.order[0].value == '')) {
if(document.form1.order.length == undefined)
{ document.form1.order.value = '1'; } else {
document.form1.order[0].value = ']]>
<xsl:value-of select="$users + 1"/><![CDATA['; }}
if(doSubmit) { document.form1.submit(); }
]]></xsl:attribute>
</INPUT>
</td>
</tr>
<tr style="background-color:#CBCCDA">
<td ALIGN="CENTER">
<xsl:attribute name="colspan">10</xsl:attribute>
  
<input type="submit" NAME="sendChanges" VALUE="Only Press Once to
Send Changes">
<xsl:attribute name="onclick"><![CDATA[ if(doSubmit) {
document.form1.submit(); } ]]></xsl:attribute>
</input>
</td>
</tr>
</table>
</xsl:template>
<xsl:template match="contact">
<tr>
<td align="center">
<xsl:value-of select="position()"/>
</td>
<td align="center">
<INPUT maxLength="30" name="name" size="28"
value="{con_nam}"/>
</td>
<td align="center">
<INPUT maxLength="12" name="priphone" size="12"
value="{con_mph}"/>
</td>
<td align="center">
<INPUT maxLength="12" name="altphone" size="12"
value="{con_aph}"/>
</td>
<td align="center">
<INPUT type="button" name="delete" value="Delete"
onclick="document.form1.itemToDelete.value={position()};document.form1.submit();"/>
</td>
</tr>
</xsl:template>

<xsl:template match="node()|@*"/>
</xsl:stylesheet>

Sample xml

<?xml version="1.0" encoding="utf-8" ?>
- <contactlist xmlns="http://www.xyz.com">
<returncode>string</returncode>
- <contacts>
- <contact>
<con_nam>John Doe</con_nam>
<con_mph>222-555-1212</con_mph>
<con_aph>222-555-1313</con_aph>
</contact>
- <contact>
<con_nam>Jane Doe</con_nam>
<con_mph>222-555-1414</con_mph>
<con_aph>222-555-1515</con_aph>
</contact>
</contacts>
</contactlist>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top