I am looking to show few extra form fields depending on the selection from a drop down menu.
For eg. in a drop down asking for payment option
if i select Online bank transfer then it should create/show a new form field below it asking for bank account number and name.
And, if i select paypal then it should ask for paypal id.
I have made this code which is working fine when i dont use form tag.
When i put this inside form field, it doesn't work.
Plz help!!!
For eg. in a drop down asking for payment option
if i select Online bank transfer then it should create/show a new form field below it asking for bank account number and name.
And, if i select paypal then it should ask for paypal id.
I have made this code which is working fine when i dont use form tag.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Show/Hide</title>
<script type="text/javascript">
// <![CDATA[
function display(obj,id1,id2,id3) {
txt = obj.options[obj.selectedIndex].value;
document.getElementById(id1).style.display = 'none';
document.getElementById(id2).style.display = 'none';
document.getElementById(id3).style.display = 'none';
if ( txt.match(id1) ) {
document.getElementById(id1).style.display = 'block';
}
if ( txt.match(id2) ) {
document.getElementById(id2).style.display = 'block';
}
if ( txt.match(id3) ) {
document.getElementById(id3).style.display = 'block';
}
}
// ]]>
</script>
</head>
<body>
<table width=70% cellspacing="0" cellpadding="2">
<thead>
<tr>
<td class="title"><font face=verdana size=2><b>Payment Option</b></font> <FONT color=#ff0000 face=Arial,Helvetica,Geneva,Sans-serif,sans-serif>*</FONT></td>
<td class="field">
<select name="type" onchange="display(this,'transfer','cheque','dd','paypal','alertpay');">
<option>Please select:</option>
<option value="transfer">Bank Account Transfer</option>
<option value="cheque">Cheque</option>
<option value="dd">Demand Draft</option>
<option value="paypal">Paypal</option>
<option value="alertpay">Alertpay</option>
</select>
</td>
</tr>
</thead>
<tfoot>
<tr>
<td class="align-center" colspan="2"><input type="submit" name="submit" value="Update" /> <input type="reset" value="Reset" /></td>
</tr>
</tfoot>
<tbody id="transfer" style="display: none;">
<tr><td><font face=verdana size=2><b>Bank Account Number</b></font> <FONT color=#ff0000 face=Arial,Helvetica,Geneva,Sans-serif,sans-serif>*</FONT></td>
<td><INPUT maxLength=55 name=account_number size=44></TD></TR>
<tr><td><font face=verdana size=2><b>Bank Name</b></font> <FONT color=#ff0000 face=Arial,Helvetica,Geneva,Sans-serif,sans-serif>*</FONT></td>
<td><INPUT maxLength=55 name=bank_name size=44></TD></TR>
<tr><td><font face=verdana size=2><b>Branch Name</b></font> <FONT color=#ff0000 face=Arial,Helvetica,Geneva,Sans-serif,sans-serif>*</FONT></td>
<td><INPUT maxLength=55 name=branch_name size=44></TD></TR>
<tr><td><font face=verdana size=2><b>Branch City</b></font> <FONT color=#ff0000 face=Arial,Helvetica,Geneva,Sans-serif,sans-serif>*</FONT></td>
<td><INPUT maxLength=55 name=branch_city size=44></TD></TR>
</tbody>
<tbody id="cheque" style="display: none;">
<tr>
<td class="title">Image:</td>
<td class="field"><input type="file" name="image" size="10" /></td>
</tr>
<tr>
<td class="title">X Coordinates:</td>
<td class="field"><input type="text" name="x_coordinates" size="5" /></td>
</tr>
<tr>
<td class="title">Y Coordinates:</td>
<td class="field"><input type="text" name="y_coordinates" size="5" /></td>
</tr>
<tr>
<td class="title">Text Color:</td>
<td class="field"><input type="text" name="color" size="8" maxlength="7" /></td>
</tr>
</tbody>
<tbody id="dd" style="display: none;">
<tr>
<td class="title">Display:</td>
<td class="field">
<select name="display">
<option value="visitors">Visitors</option>
<option value="hits">Hits</option>
</select>
</td>
</tr>
</tbody>
</table>
</body>
</html>
When i put this inside form field, it doesn't work.
Plz help!!!