Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2006
    Posts
    56

    Unanswered: Field names (might be silly)

    Hi, guys!

    Here's my issue


    I have a dynamic form table that creates rows based on a query result. So... Better to check it out:

    Code:
    ...
    
    <%
    	objRS.open SQL, objConn
    		if (objRS.eof) then
    %>
                <tr>
                  <td colspan="4" class="GreenTahoma11Bold">
                    <div align="center" style="padding: 2px 0px 2px 0px; "> No records found. </div></td>
                </tr>
    <% 
    		else 
    %>
    
                <tr>
                  <td class="BlackTahoma11"><div style="padding: 2px 0px 0px 2px; "> Paying Options </div></td>
                  <td align="center" class="BlackTahoma11">Ammount (R$) </td>
                  <td class="BlackTahoma11"><div align="center">Change (R$) </div></td>
                  <td class="BlackTahoma11">&nbsp;</td>
                </tr>
                <!--#include file="includes/color_switch_invert.inc"--> <% 'just to alternate the td bgcolors between white and lightgrey %>
    
    
    <%
    			do until (objRS.eof)
    %>
    
                <tr bgcolor="<%= color %>">
                  <td width="160" class="BlackTahoma11">
                    <div style="padding: 2px 0px 2px 2px; "> <%= objRS("desc_payment_opt") %> </div></td>
                  <td width="80"><div align="center">
                      <input name="ammount" id="ammount" type="text" class="Input40" value="<%= fixMoney(objRS("ammount")) %>" onBlur="newAmmount(<%= objRS("id") %>, this.value);">
    				  
                  </div></td>
                  <td width="90"><div align="center">
                      <input name="change" id="change" type="text" class="Input40" value="<%= fixMoney(objRS("change")) %>" onBlur="newChange(<%= objRS("id") %>,this.value);">
                  </div></td>
    
    			  <td width="208">
                    <div align="right" style="padding: 2px 2px 0px 0px; "> 
    				  <a href="javascript:void(0)"><img src="images/icon_v.jpg" alt="New Ammount" width="16" height="16" border="0"></a>
    				  <a href="goto.asp?act=del&sid=<%= objRS("id") %>" target="_parent" ><img src="images/icon_x.jpg" alt="Delete Payment Choice" width="16" height="16" border="0"></a>
    				</div>
    			  </td>
                </tr>
    
    <%
    				objRS.movenext
    %>
    
    <!--#include file="includes/color_switch_do.inc"-->
    
    <%
    			loop
    		end if
    	objRS.close
    '====================================================================================
    %>
    
              </table>
    Ok, now what I want is simple. I want to dynamically focus on the "ammount" field. So, if my query returns only one record, I'm fine. But if returns more than one, there will be more than one "ammount" fields.

    That means that something like document.form.ammount.focus(); will generate a script error.

    I thought that they would automaticcaly be named ammount[i] or something, but they are not...

    Can anybody help me?

    Sorry about my poor English, and any help would be appreciated.

  2. #2
    Join Date
    Jul 2006
    Posts
    56

    got it

    Well...

    I guess this should be in a JavaScript forum...

    Anyways, I used the getElementById() to solve the problem.

    Dunno if this could help anybody, but if it can, lemme know and I'll show how I came around.

    Cheers

Posting Permissions

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