www.webdeveloper.com
Results 1 to 10 of 10

Thread: Urgent Please Help!!!

  1. #1
    Join Date
    May 2005
    Posts
    43

    Urgent Please Help!!!

    In my ASP page I am reteriving records from the database and displaying it to the user...
    For each record I display the following:
    1) LOI
    2) Contract Sent
    3) Contract received
    4) Contract Execeuted
    5) MIIP Incentive Sent
    6) MIIP Incentive Received
    7) RTS Incentive Sent
    8) RTS Incentive Received

    For the above if I get a date from the recordet I display the date else a checkbox for the user to select...
    Once the user selects a checkbox and clicks on the SAVE button...I need to insert a record in my table for example:
    LOI - CurrentTimeStamp

    So for the checkboxes selected by user for that particular row I need to insert as above in database...

    I am finding it difficult to do this as I my new to ASP..
    Could anyone of you please help me...

    Please find the code below:

    <form name="frmSelect" method="post" action="chk.asp">
    <table width=700 border=1>
    <%

    Do While Not rs.EOF

    %>

    <tr>


    <%
    If rs.Fields(7) <> "" Then
    %>
    <td width=50><input name="LOI<%=rs.Fields(0)%>" type="hidden" id="LOI<%=rs.Fields(0)%>" value="LOI<%=rs.Fields(0)%>"><%=rs.Fields(7)%></td>

    <%Else%>
    <td width=50><input name="LOI<%=rs.Fields(0)%>" type="checkbox" id="LOI<%=rs.Fields(0)%>" value="LOI<%=rs.Fields(0)%>" onclick="checkLOI(parseFloat(this.name.substr(3)))"></td>
    <%End If%>
    <%
    If rs.Fields(8) <> "" Then
    %>
    <td width=50><input name="CONTRACT_SENT<%=rs.Fields(0)%>" type="hidden" id="CONTRACT_SENT<%=rs.Fields(0)%>" value="CONTRACT_SENT<%=rs.Fields(0)%>"><%=rs.Fields(8)%></td>

    <%Else%>
    <%If rs.Fields(7) <> "" Then%>
    <td width=50><input name="CONTRACT_SENT<%=rs.Fields(0)%>" type="checkbox" id="CONTRACT_SENT<%=rs.Fields(0)%>" value="CONTRACT_SENT<%=rs.Fields(0)%>" onclick="checkCTS(parseFloat(this.name.substr(13)))"></td>
    <%Else%>
    <td width=50><input name="CONTRACT_SENT<%=rs.Fields(0)%>" type="checkbox" id="CONTRACT_SENT<%=rs.Fields(0)%>" value="CONTRACT_SENT<%=rs.Fields(0)%>" onclick="checkCTS(parseFloat(this.name.substr(13)))" disabled="disabled"></td>
    <%End If%>
    <%End If%>
    <%
    If rs.Fields(9) <> "" Then
    %>
    <td width=50><input name="CONTRACT_RECEIVED<%=rs.Fields(0)%>" type="hidden" id="CONTRACT_RECEIVED<%=rs.Fields(0)%>" value="CONTRACT_RECEIVED<%=rs.Fields(0)%>"><%=rs.Fields(9)%></td>

    <%Else%>
    <%If rs.Fields(8) <> "" Then%>
    <td width=50><input name="CONTRACT_RECEIVED<%=rs.Fields(0)%>" type="checkbox" id="CONTRACT_RECEIVED<%=rs.Fields(0)%>" value="CONTRACT_RECEIVED<%=rs.Fields(0)%>" onclick="checkCTR(parseFloat(this.name.substr(17)))"></td>
    <%Else%>
    <td width=50><input name="CONTRACT_RECEIVED<%=rs.Fields(0)%>" type="checkbox" id="CONTRACT_RECEIVED<%=rs.Fields(0)%>" value="CONTRACT_RECEIVED<%=rs.Fields(0)%>" onclick="checkCTR(parseFloat(this.name.substr(17)))" disabled="disabled"></td>
    <%End If%>
    <%End If%>
    <%
    If rs.Fields(10) <> "" Then
    %>
    <td width=50><input name="CONTRACT_EXECUTED<%=rs.Fields(0)%>" type="hidden" id="CONTRACT_EXECUTED<%=rs.Fields(0)%>" value="CONTRACT_EXECUTED<%=rs.Fields(0)%>"><%=rs.Fields(10)%></td>

    <%Else%>
    <%If rs.Fields(9) <> "" Then%>
    <td width=50><input name="CONTRACT_EXECUTED<%=rs.Fields(0)%>" type="checkbox" id="CONTRACT_EXECUTED<%=rs.Fields(0)%>" value="CONTRACT_EXECUTED<%=rs.Fields(0)%>"></td>
    <%Else%>
    <td width=50><input name="CONTRACT_EXECUTED<%=rs.Fields(0)%>" type="checkbox" id="CONTRACT_EXECUTED<%=rs.Fields(0)%>" value="CONTRACT_EXECUTED<%=rs.Fields(0)%>" disabled="disabled"></td>
    <%End If%>
    <%End If%>
    <%
    If rs.Fields(11) <> "" Then
    %>
    <td width=50><input name="MIIP_SENT<%=rs.Fields(0)%>" type="hidden" id="MIIP_SENT<%=rs.Fields(0)%>" value="MIIP_SENT<%=rs.Fields(0)%>"><%=rs.Fields(11)%></td>
    <%Else%>
    <td width=50><input name="MIIP_SENT<%=rs.Fields(0)%>" type="checkbox" id="MIIP_SENT<%=rs.Fields(0)%>" value="MIIP_SENT<%=rs.Fields(0)%>" onclick="checkMIIP(parseFloat(this.name.substr(9)))"></td>
    <%End If%>
    <%
    If rs.Fields(12) <> "" Then
    %>
    <td width=50><input name="MIIP_RECEIVED<%=rs.Fields(0)%>" type="hidden" id="MIIP_RECEIVED<%=rs.Fields(0)%>" value="MIIP_RECEIVED<%=rs.Fields(0)%>"><%=rs.Fields(12)%></td>

    <%Else%>
    <%If rs.Fields(11) <> "" Then%>
    <td width=50><input name="MIIP_RECEIVED<%=rs.Fields(0)%>" type="checkbox" id="MIIP_RECEIVED<%=rs.Fields(0)%>" value="MIIP_RECEIVED<%=rs.Fields(0)%>"></td>
    <%Else%>
    <td width=50><input name="MIIP_RECEIVED<%=rs.Fields(0)%>" type="checkbox" id="MIIP_RECEIVED<%=rs.Fields(0)%>" value="MIIP_RECEIVED<%=rs.Fields(0)%>" disabled="disabled"></td>
    <%End If%>
    <%End If%>
    <%
    If rs.Fields(13) <> "" Then
    %>
    <td width=50><input name="RTS_SENT<%=rs.Fields(0)%>" type="hidden" id="RTS_SENT<%=rs.Fields(0)%>" value="RTS_SENT<%=rs.Fields(0)%>"><%=rs.Fields(13)%></td>
    <%Else%>
    <td width=50><input name="RTS_SENT<%=rs.Fields(0)%>" type="checkbox" id="RTS_SENT<%=rs.Fields(0)%>" value="RTS_SENT<%=rs.Fields(0)%>" onclick="checkRTS(parseFloat(this.name.substr(8)))"></td>
    <%End If%>
    <%
    If rs.Fields(14) <> "" Then
    %>
    <td width=50><input name="RTS_RECEIVED<%=rs.Fields(0)%>" type="hidden" id="RTS_RECEIVED<%=rs.Fields(0)%>" value="RTS_RECEIVED<%=rs.Fields(0)%>"><%=rs.Fields(14)%></td>
    <%Else%>
    <%If rs.Fields(13) <> "" Then%>
    <td width=50><input name="RTS_RECEIVED<%=rs.Fields(0)%>" type="checkbox" id="RTS_RECEIVED<%=rs.Fields(0)%>" value="RTS_RECEIVED<%=rs.Fields(0)%>"></td>
    <%Else%>
    <td width=50><input name="RTS_RECEIVED<%=rs.Fields(0)%>" type="checkbox" id="RTS_RECEIVED<%=rs.Fields(0)%>" value="RTS_RECEIVED<%=rs.Fields(0)%>" disabled="disabled"></td>
    <%End If%>
    <%End If%>


    </tr>

    <%
    rs.MoveNext
    Loop
    %>
    </table>
    <input type="submit" value="SAVE">
    <input type="hidden" name="Process" value="True">


    </form>

    Please help me...

  2. #2
    Join Date
    Apr 2005
    Location
    kali
    Posts
    308
    looks like you have a javascript function but i dont see it in the code. are you trying to use the javascript function to do the database work?

    edit: just a general tip, use the name of the column in the rs.fields("column_name") instead of numeric id. its just easier to read and follow.

  3. #3
    Join Date
    May 2005
    Posts
    43
    I have a javascript function for validation of these checkboxes...I am not using them for inserting in database:

    JS Function:
    <script type="text/javascript">
    function checkLOI(myIndex){
    var x=document.forms.frmSelect

    if(x["LOI"+myIndex].checked==true && x["LOI"+myIndex].value !=""){
    x["CONTRACT_SENT"+myIndex].disabled = false;
    x["CONTRACT_RECEIVED"+myIndex].disabled = true;
    x["CONTRACT_EXECUTED"+myIndex].disabled = true;
    }

    if(x["LOI"+myIndex].checked==false || x["LOI"+myIndex].value ==""){
    x["CONTRACT_SENT"+myIndex].checked = false;
    x["CONTRACT_SENT"+myIndex].disabled = true;
    }

    }

    function checkCTS(myIndex){
    var x=document.forms.frmSelect
    if(x["CONTRACT_SENT"+myIndex].checked==true && x["CONTRACT_SENT"+myIndex].value != ""){
    x["CONTRACT_SENT"+myIndex].disabled = false;
    x["CONTRACT_RECEIVED"+myIndex].disabled = false;
    x["CONTRACT_EXECUTED"+myIndex].disabled = true;
    }

    if(x["CONTRACT_SENT"+myIndex].checked==false || x["CONTRACT_SENT"+myIndex].value == ""){
    x["CONTRACT_RECEIVED"+myIndex].checked = false;
    x["CONTRACT_RECEIVED"+myIndex].disabled = true;
    }
    }

    function checkCTR(myIndex){
    var x=document.forms.frmSelect
    if(x["CONTRACT_RECEIVED"+myIndex].checked == true && x["CONTRACT_RECEIVED"+myIndex].value != ""){
    x["CONTRACT_EXECUTED"+myIndex].disabled = false;
    }

    if(x["CONTRACT_RECEIVED"+myIndex].checked == false || x["CONTRACT_RECEIVED"+myIndex].value == ""){
    x["CONTRACT_EXECUTED"+myIndex].checked = false;
    x["CONTRACT_EXECUTED"+myIndex].disabled = true;
    }
    }

    function checkMIIP(myIndex){
    var x=document.forms.frmSelect
    if(x["MIIP_SENT"+myIndex].checked==true && x["MIIP_SENT"+myIndex].value !=""){
    x["MIIP_RECEIVED"+myIndex].disabled = false;
    }

    if(x["MIIP_SENT"+myIndex].checked==false || x["MIIP_SENT"+myIndex].value ==""){
    x["MIIP_RECEIVED"+myIndex].checked = false;
    x["MIIP_RECEIVED"+myIndex].disabled = true;
    }
    }

    function checkRTS(myIndex){
    var x=document.forms.frmSelect
    if(x["RTS_SENT"+myIndex].checked==true && x["RTS_SENT"+myIndex].value !=""){
    x["RTS_RECEIVED"+myIndex].disabled = false;
    }

    if(x["RTS_SENT"+myIndex].checked==false || x["RTS_SENT"+myIndex].value ==""){
    x["RTS_RECEIVED"+myIndex].checked = false;
    x["RTS_RECEIVED"+myIndex].disabled = true;
    }
    }
    </script>

  4. #4
    Join Date
    May 2005
    Posts
    43
    and this is the updated code with column names...learning some good things today

    Updated Code:
    <%
    If rs.Fields(LOI) <> "" Then
    %>
    <td width=50><input name="LOI<%=rs.Fields(FACILITY_ID)%>" type="hidden" id="LOI<%=rs.Fields(FACILITY_ID)%>" value="LOI<%=rs.Fields(FACILITY_ID)%>"><%=rs.Fields(LOI)%></td>

    <%Else%>
    <td width=50><input name="LOI<%=rs.Fields(FACILITY_ID)%>" type="checkbox" id="LOI<%=rs.Fields(FACILITY_ID)%>" value="LOI<%=rs.Fields(FACILITY_ID)%>" onclick="checkLOI(parseFloat(this.name.substr(3)))"></td>
    <%End If%>
    <%
    If rs.Fields(CONTRACT_SENT) <> "" Then
    %>
    <td width=50><input name="CONTRACT_SENT<%=rs.Fields(FACILITY_ID)%>" type="hidden" id="CONTRACT_SENT<%=rs.Fields(FACILITY_ID)%>" value="CONTRACT_SENT<%=rs.Fields(FACILITY_ID)%>"><%=rs.Fields(CONTRACT_SENT)%></td>

    <%Else%>
    <%If rs.Fields(LOI) <> "" Then%>
    <td width=50><input name="CONTRACT_SENT<%=rs.Fields(FACILITY_ID)%>" type="checkbox" id="CONTRACT_SENT<%=rs.Fields(FACILITY_ID)%>" value="CONTRACT_SENT<%=rs.Fields(FACILITY_ID)%>" onclick="checkCTS(parseFloat(this.name.substr(13)))"></td>
    <%Else%>
    <td width=50><input name="CONTRACT_SENT<%=rs.Fields(FACILITY_ID)%>" type="checkbox" id="CONTRACT_SENT<%=rs.Fields(FACILITY_ID)%>" value="CONTRACT_SENT<%=rs.Fields(FACILITY_ID)%>" onclick="checkCTS(parseFloat(this.name.substr(13)))" disabled="disabled"></td>
    <%End If%>
    <%End If%>
    <%
    If rs.Fields(CONTRACT_RECEIVED) <> "" Then
    %>
    <td width=50><input name="CONTRACT_RECEIVED<%=rs.Fields(FACILITY_ID)%>" type="hidden" id="CONTRACT_RECEIVED<%=rs.Fields(FACILITY_ID)%>" value="CONTRACT_RECEIVED<%=rs.Fields(FACILITY_ID)%>"><%=rs.Fields(CONTRACT_RECEIVED)%></td>

    <%Else%>
    <%If rs.Fields(CONTRACT_SENT) <> "" Then%>
    <td width=50><input name="CONTRACT_RECEIVED<%=rs.Fields(FACILITY_ID)%>" type="checkbox" id="CONTRACT_RECEIVED<%=rs.Fields(FACILITY_ID)%>" value="CONTRACT_RECEIVED<%=rs.Fields(FACILITY_ID)%>" onclick="checkCTR(parseFloat(this.name.substr(17)))"></td>
    <%Else%>
    <td width=50><input name="CONTRACT_RECEIVED<%=rs.Fields(FACILITY_ID)%>" type="checkbox" id="CONTRACT_RECEIVED<%=rs.Fields(FACILITY_ID)%>" value="CONTRACT_RECEIVED<%=rs.Fields(FACILITY_ID)%>" onclick="checkCTR(parseFloat(this.name.substr(17)))" disabled="disabled"></td>
    <%End If%>
    <%End If%>
    <%
    If rs.Fields(CONTRACT_EXECUTED) <> "" Then
    %>
    <td width=50><input name="CONTRACT_EXECUTED<%=rs.Fields(FACILITY_ID)%>" type="hidden" id="CONTRACT_EXECUTED<%=rs.Fields(FACILITY_ID)%>" value="CONTRACT_EXECUTED<%=rs.Fields(FACILITY_ID)%>"><%=rs.Fields(CONTRACT_EXECUTED)%></td>

    <%Else%>
    <%If rs.Fields(CONTRACT_RECEIVED) <> "" Then%>
    <td width=50><input name="CONTRACT_EXECUTED<%=rs.Fields(FACILITY_ID)%>" type="checkbox" id="CONTRACT_EXECUTED<%=rs.Fields(FACILITY_ID)%>" value="CONTRACT_EXECUTED<%=rs.Fields(FACILITY_ID)%>"></td>
    <%Else%>
    <td width=50><input name="CONTRACT_EXECUTED<%=rs.Fields(FACILITY_ID)%>" type="checkbox" id="CONTRACT_EXECUTED<%=rs.Fields(FACILITY_ID)%>" value="CONTRACT_EXECUTED<%=rs.Fields(FACILITY_ID)%>" disabled="disabled"></td>
    <%End If%>
    <%End If%>
    <%
    If rs.Fields(MIIP_SENT) <> "" Then
    %>
    <td width=50><input name="MIIP_SENT<%=rs.Fields(FACILITY_ID)%>" type="hidden" id="MIIP_SENT<%=rs.Fields(FACILITY_ID)%>" value="MIIP_SENT<%=rs.Fields(FACILITY_ID)%>"><%=rs.Fields(MIIP_SENT)%></td>
    <%Else%>
    <td width=50><input name="MIIP_SENT<%=rs.Fields(FACILITY_ID)%>" type="checkbox" id="MIIP_SENT<%=rs.Fields(FACILITY_ID)%>" value="MIIP_SENT<%=rs.Fields(FACILITY_ID)%>" onclick="checkMIIP(parseFloat(this.name.substr(9)))"></td>
    <%End If%>
    <%
    If rs.Fields(MIIP_RECEIVED) <> "" Then
    %>
    <td width=50><input name="MIIP_RECEIVED<%=rs.Fields(FACILITY_ID)%>" type="hidden" id="MIIP_RECEIVED<%=rs.Fields(FACILITY_ID)%>" value="MIIP_RECEIVED<%=rs.Fields(FACILITY_ID)%>"><%=rs.Fields(MIIP_RECEIVED)%></td>

    <%Else%>
    <%If rs.Fields(MIIP_SENT) <> "" Then%>
    <td width=50><input name="MIIP_RECEIVED<%=rs.Fields(FACILITY_ID)%>" type="checkbox" id="MIIP_RECEIVED<%=rs.Fields(FACILITY_ID)%>" value="MIIP_RECEIVED<%=rs.Fields(FACILITY_ID)%>"></td>
    <%Else%>
    <td width=50><input name="MIIP_RECEIVED<%=rs.Fields(FACILITY_ID)%>" type="checkbox" id="MIIP_RECEIVED<%=rs.Fields(FACILITY_ID)%>" value="MIIP_RECEIVED<%=rs.Fields(FACILITY_ID)%>" disabled="disabled"></td>
    <%End If%>
    <%End If%>
    <%
    If rs.Fields(RTS_SENT) <> "" Then
    %>
    <td width=50><input name="RTS_SENT<%=rs.Fields(FACILITY_ID)%>" type="hidden" id="RTS_SENT<%=rs.Fields(FACILITY_ID)%>" value="RTS_SENT<%=rs.Fields(FACILITY_ID)%>"><%=rs.Fields(RTS_SENT)%></td>
    <%Else%>
    <td width=50><input name="RTS_SENT<%=rs.Fields(FACILITY_ID)%>" type="checkbox" id="RTS_SENT<%=rs.Fields(FACILITY_ID)%>" value="RTS_SENT<%=rs.Fields(FACILITY_ID)%>" onclick="checkRTS(parseFloat(this.name.substr(8)))"></td>
    <%End If%>
    <%
    If rs.Fields(RTS_RECEIVED) <> "" Then
    %>
    <td width=50><input name="RTS_RECEIVED<%=rs.Fields(FACILITY_ID)%>" type="hidden" id="RTS_RECEIVED<%=rs.Fields(FACILITY_ID)%>" value="RTS_RECEIVED<%=rs.Fields(FACILITY_ID)%>"><%=rs.Fields(RTS_RECEIVED)%></td>
    <%Else%>
    <%If rs.Fields(RTS_SENT) <> "" Then%>
    <td width=50><input name="RTS_RECEIVED<%=rs.Fields(FACILITY_ID)%>" type="checkbox" id="RTS_RECEIVED<%=rs.Fields(FACILITY_ID)%>" value="RTS_RECEIVED<%=rs.Fields(FACILITY_ID)%>"></td>
    <%Else%>
    <td width=50><input name="RTS_RECEIVED<%=rs.Fields(FACILITY_ID)%>" type="checkbox" id="RTS_RECEIVED<%=rs.Fields(FACILITY_ID)%>" value="RTS_RECEIVED<%=rs.Fields(FACILITY_ID)%>" disabled="disabled"></td>
    <%End If%>
    <%End If%>


    </tr>

    <%
    rs.MoveNext
    Loop
    %>
    </table>
    <input type="submit" value="Submit">
    <input type="hidden" name="Process" value="True">


    </form>

  5. #5
    Join Date
    Apr 2005
    Location
    kali
    Posts
    308
    the column names need to have "double quotes" around them.

    are you wanting the database action when they check the box or when they submit the form?

  6. #6
    Join Date
    May 2005
    Posts
    43
    when the users submit the form...
    they can check the boxes which they wish to and then click on the SAVE button....which will take the check box values insert in the database....

    the form should get submitted and reterive the latest values from the database...

  7. #7
    Join Date
    Apr 2005
    Location
    kali
    Posts
    308
    in the page you are posting to, start checking the value of the checkboxes you have. if theres a value, then do a select to see if the row is already in the database. if its not there, then insert it and move onto the next box.

  8. #8
    Join Date
    May 2005
    Posts
    43
    how do i do this...

  9. #9
    Join Date
    Apr 2005
    Location
    kali
    Posts
    308
    do you know asp?

  10. #10
    Join Date
    May 2005
    Posts
    43
    no I am new to ASP...please help

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles