Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic HTML table and 3 dynamic radio buttons 1

Status
Not open for further replies.

JohnShell

Technical User
Aug 29, 2003
35
US
Hi,

I have an HTML table dynamically populated with data from a coldfusion query and having radio buttons - see code following below.

I need javascript to see the radio buttons and the user's selection - "approved"; "denied"; or, "N/A". If the user selects "approved" for multiple rows and then Submit the information will update the database table and remove those rows.
However, if the user selects "approved" and "denied" then I need to update the "approved" rows and stop the update at the "denied" row and show a dialog box which informs the user that the "Reason for Denial" text box must be entered. Then the Submit button can be engaged and the "denied" selection processed. Only one "denied" at a time will be updated - but all "approved" entries can be denied similtaneously - unless a "denied" intervenes.
I do have javascript code for the "denied" selection with empty "Reason for Denial" text box - see below:


Code:
<script type="text/javascript">
	function rationale() {
		var denInfo = document.getElementById("denialReason");
		if(denInfo.value == ""){ 
			alert("Please enter reason for denial in Rationale for Request Denial");
			return false;
			denInfo.focus();		
		}
	}
</script>

The overall action seems like it would need some extensive javascript coding and I haven't a clue how to do it. Any help is GREATLY APPRECIATED.


Code:
<table border="1" cellspacing="1" cellpadding="2" style="position:relative; left:50px;" width="1000">
    <tr>
        <td width="140" align="center" bgcolor="#FEF9E7"><font color="#0000FF" style="font-weight:bold;">&nbsp;&nbsp;Name<hr />Begin Date</font></td>
        <td width="75" align="center" bgcolor="#FEF9E7"><font color="#0000FF" style="font-weight:bold;">&nbsp;&nbsp;Request Date<hr />End Date</font></td>
        <td width="145" align="center" bgcolor="#FEF9E7"><font color="#0000FF" style="font-weight:bold;">Type of Hrs<hr />Request Justification</font></td>
        <td width="76" align="center" bgcolor="#FEF9E7"><font color="#0000FF" style="font-weight:bold;">&nbsp;Num Hrs Req<hr />Rel Comp Begin Date</font></td>
        <td width="98" align="center" bgcolor="#FEF9E7"><font color="#0000FF" style="font-weight:bold;">&nbsp;Projects<hr />Rel Comp End Date</font></td>
        <td width="180" align="center" bgcolor="#FEF9E7"><font color="#0000FF" style="font-weight:bold;">&nbsp;&nbsp;Decision<hr />Leave Slip Submitted</font></td>
    </tr>
	<cfoutput query="Req"> 
    <tr style="background-color:'FFFFFF';" onMouseOver="this.style.backgroundColor='FFCC33';" onMouseOut="this.style.backgroundColor='FFFFFF'" >
        <td colspan="6">
            <table cols="6" border="1" cellpadding="5" cellspacing="0">
                <tr>
                    <td width="177">&nbsp;#Name#</td>
                    <td width="107">&nbsp;#DateFormat(RequestDate, "m/d/yyyy")#</td>
                    <td width="178">&nbsp;#TypeofHours#</td>
                    <td width="105">&nbsp;#NumberHrsRequested#</td>
                    <td width="127">&nbsp;#project#</td>
                    <td width="218">&nbsp;#Decision#
                        <cfinput name="Decision_#ID#" id="Decision_#ID#" type="radio" value="approved" size="1">Approve 
                        <cfinput name="Decision_#ID#" id="Decision_#ID#" type="radio" value="denied" size="1">Deny
                        <cfinput name="Decision_#ID#" id="Decision_#ID#" type="radio" value="" size="1" checked="yes">N/A
                    </td> 
                </tr>
                <tr>
                    <td>&nbsp;#DateFormat(BeginDate, "m/d/yyyy")#</td>
                    <td>&nbsp;#DateFormat(EndDate, "m/d/yyyy")#</td>
                    <td>&nbsp;#justification#</td>
                    <td>&nbsp;#DateFormat(RCBDate, "m/d/yyyy")#</td>
                    <td>&nbsp;#DateFormat(RCEDate, "m/d/yyyy")#</td>
                    <td>&nbsp;#RCLeaveSlip#</td>    
                </tr>
                <tr id="denyRow_#ID#">
                    <td colspan="1"><font color="##0000FF"; style="font-weight:bold">Reason For Denial</font></td>
                    <td colspan="5">&nbsp; #ReasonForDenial#
                    	<cftextarea name="denial_#ID#" cols="85" rows="3" wrap="hard"/>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    </cfoutput>  
</table>

Thank you,

John
 
You can't really break the update process like that. Javascript only runs on the browser, as such once the data is submitted to the server, Javascript can do nothing else.

____________________ ______________________
| | | Server/Coldfusiuon |
| Browser/Javascript | ----->| DB Update |
|____________________| |______________________|


What you can do, is have JS check all the rows for the presence of the denied reason if the denied radio is selected, and then submit the data to the server so Coldfusion can update the database.

You could limit the data sending if more than one row is found to be denied, but you can't go back and forth sequentially.









----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Phil AKA Vacunita,

Great point - of course js only affects browser side. Altering code accordingly.

Many thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top