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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Each Row Submit Button

Status
Not open for further replies.
May 9, 2000
446
GB
Hi I have a page that lists all usernames + passwords as rows with each having a submit buttone.g.

UserName Password
___________________________________________
MyUsername Mypassword 'Submit button'
YourUsername Yourpassword 'Submit Button'



The username and password are displayed in text boxes so an admin can access the page and update usernames and passwords, problem is that I'm not sure how to make the submit buttons relate to the row (username/password) they represent?

I've put the unique ID of each user as the name of the submit button but am now a bit lost! Can anyone show me how to get this done?

Ta
 
the danger of your chosen method is you could update all the item at each submit

better way is to display all the usernames etc and have a radio button with the value set as the unique id, with just one submit button. The checkbox value can be used to show the edit form with only that user selected. the submit then sends updated info to the database.

Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
If you "need" to do it that way then create a form for to house each set of controls & button. Something like:

Code:
<%
do while not rs.eof
   myUniqueId = rs("ID")
   UserName = rs("UserName")
   Password = rs("Password")
   Counter = Counter + 1
%>
<form name="frm<%=Counter%>" method="Post" action="YourProcessingPage.asp">
<input type="text name="UserName" value="<%=UserName>">
<input type="text" name="Password" value="<%=Password%>">
<input type="submit" name="btnSubmit" value="Update">
<input type="hidden" name="myUniqueID" value="<%=myUniqueID%>">
</form>

<%
   rs.movenext
loop
set rs = nothing
This way when you click the submit button it will pass only the specific UserName, Password and RecordID to the processing page.
 
Or you could set up a single form and use some client-side scripting to set the values forthe one you want to submit:
Code:
<!-- In the head section -->
<script language="javascript">
function setValues(num){
   MyForm.Username.value = document.getElementsByName("Username"+num)[0].value;
   MyForm.Password.value = document.getElementsByName("Password"+num)[0].value;
   MyForm.uniqueId.value = document.getElementsByName("uniqueId"+num)[0].value;
   MyForm.submit();
}
</script>

<!-- Body -->
<form method="POST" action="processing.asp" name="MyForm">
<input type="hidden" name="Username">
<input type="hidden" name="password">
<input type="hidden" name="uniqueId">
</form>
<table>
<%
Dim ctr
Do Until rs.EOF
   ctr = ctr + 1
   %>
   <tr>
      <td><input type="text" name="Username<%=ctr%>" value="<%=rs("username")%>"></td>
      <td><input type="text" name="Password<%=ctr%>" value="<%=rs("password")%>"></td>
      <td>
         <input type="hidden" name="uniqueId<%=ctr%>" value="<%=rs("uniqueId")%>">
         <input type="button" onClick="SetValues(<%=ctr%>);">
      </td>
   </tr>
   <%
   rs.MoveNext
Loop
%>

This was written on the fly so i can't guarantee it will work first shot (or cross browser) but the concept should be correct,

-T

barcode_1.gif
 
cheers for the responses everyone, I'ev gone with Veeps method cuz I thought it looked easiest + I know pretty much nothing about javascript!

Cheers again
 
After searching high and low, I finally found this and it worked great. Here is a star for ya veep!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top