So I think I'm in some kind of tunnel-vision right now.
I have to maintain a very basic application (HTML + ASP). In this application, there is a small table with some values:
<table>
<tr>
<td>Customer-ID</td>
</tr>
<tr>
<td>Waregroup</td>
</tr>
<tr>
<td>Some other ID</td>
</tr>
<tr>
<td>[edit]</td>
</tr>
<tr>
<td>[delete]</td>
</tr>
<tr>
<td>[checkbox for deletion]</td>
</tr>
</table>
It looks like this, to make it more visual (excluded the rows with data, they are not needed for this):
Now, the delete-function just doesn't take simply the customer-id (KD Nr.), it takes several more arguments, which are provided in a link. For example, this here:
someSite.com?sid=123456&gkid=133&kdid=9043168&wws=9&del=1
Some of the values are taken from the QueryString, other from a ResultSet from a SQL-Query.
Now I had to extend this application and add a checkbox to bulk-deletion. This wasn't a problem at all, but now I'm kinda stuck on how to get the values which are required for the deletion, when I can basically just use 1 value in each checkbox. I thought about using hidden inputs, but then I have no idea how to determine, which "rows" should be deleted and which not:
This is the addtion I made:
<td>
<input type="checkbox" name="deletebox[]" value="0">
<input type="hidden" name="sid" value="<%=Request.QueryString("sid")%>">
<input type="hidden" name="gkid" value="<%=Request.QueryString("gkid")%>">
<input type="hidden" name="kdid" value="<%=rs("ka_kdnr")%>">
<input type="hidden" name="wws" value="<%=rs("ka_sysid")%>">
</td>
My idea is to loop through every checked checkbox, take the values from the hidden fields and run my deletion-script in a loop.
Any lead on how to do so? Can I simply iterate over all checked checkboxes and request for the current value of the hidden fields?
I basically just need the gkid and the gkkid for the stored procedure to work.
If you submit a form which contains multiple instances of the same form variable then that the value of that variable in the Request object will appear as a comma separated array. In other words if your form contains the following:
<input type="checkbox" name="gkid" value="25">
<input type="checkbox" name="gkid" value="50">
<input type="checkbox" name="gkid" value="75">
Then Request("gkid") will display a value of "25,50,75" if you check all of them. You can then split your array as follows.
For i = 1 to Request("gkid").Count
Response.write Request("gkid")(i) & "<br>" & vbcrlf
Next
I'm going to assume that you can take it from there and adapt the above to use Request.Form("gkid")(i) and apply logic inside the loop with code which calls your stored procedure.
Your question mentions a variable called "gkkid". I can't see where that comes from. If I could I might be able to improve on this answer.
Related
I'm new to Gatling and have to design a performance test. I need to login with several users, who each have different possibilities to choose from. Each possibility has the option to choose it or not and looks somewhat like this in the HTML-Code (simplified)
<input type="radio" name="Name123" value="1" checked="checked" class="uebernehmen">
I need to give the Element under name in formParam in the script. In this case, that is Name123. Like I said, the possibilities are different for each user and each possibility has a different value under name. Is there any way to get that value from the first possibility in the form?
It might be important to say, that if not obvious already, this is just a part of a form and there are various of these, packed in more HTML. One of these elements inside the form would look like this.
<tr>
<tbody class="tagcontent" id="ID"><tr id="ID" class="kurs" >
<td>
<input type="radio" name="Name123" value="1" class="uebernehmen">
</td>
<td>
<input type="radio" name="Name123" value="2" class="abwaehlen">
</td>
</tbody>
</tr>
In addition there is following block at the beginning of the form, where I need to extract the value of PersonID and AccountID, is that possible too?
<input type="hidden" name="PersonID" value="IDP">
<input type="hidden" name="AccountID" value="IDA">
Thanks in advance!
Use a CSS selector check like demoed in the tutorial and in the Gatling Academy.
I am developing a django/html application where I have a table of data. I have to make a way for my users to delete multiple rows in a table. Therefore, I have decided to add checkboxes in a list.
I know that I can include it as
<tr>
<td><input type="radio" name="item1" /></td>
<td>Item1</td>
</tr>
<tr>
<td><input type="radio" name="item2" /></td>
<td>Item2</td>
</tr>
for each item. Then in the end, I can add:
<input type="submit" name="delete" value="Delete Items" />
But this will mean that I will have to enclose my list within a <form></form>
Is this an ethical way of doing it?
I want to add this feature to my site but I also want to do it in the most professional way. Can anyone tell me if I am going in the right direction?
Since you use Django, one way would be to take advantage of what Django provides for forms.
Here are the examples from the official doc, for version 1.10:
-for the radio buttons:
https://docs.djangoproject.com/en/1.10/ref/forms/widgets/#widgets-inheriting-from-the-select-widget
-for the form:
https://docs.djangoproject.com/en/1.10/topics/forms/#building-a-form-in-django
A django form uses the form tag.
Basically, I have a table with inputs inside a form tag, that are required by user to fill in.
When I test it, the form is working, but only when there is one row in a table. With two an more rows, a required attribute is not working.
I've written a simple example
This works, click enter inside input field to see.
<form>
<table>
<tr>
<td>
<input type="text" name="usrname" required>
</td>
</tr>
</table>
</form>
<br>
This doesn't work, click enter inside input field to see.
<form>
<table>
<tr>
<td>
<input type="text" name="usrname" required>
</td>
</tr>
<tr>
<td>
<input type="text" name="surname" required>
</td>
</tr>
</table>
</form>
That's because forms with more than one text input aren't submitted by hitting enter. Try adding a submit button to both forms and you'll see it works fine.
In your example, is that supposed to be two identical fields in the different cells (and one of them is just misspelled)? If so, that's likely your problem. If they are intended to be two separate fields, it should work, but I'd need to see a more real-world example.
Also, I'd highly recommend using CSS to format/style your form. If that sounds intimidating, try Bootstrap--it makes creating pretty forms extremely easy.
Don't know a better title but here is what im trying to do.
I have the following form where which will display a list of books and after every book entry there is a remove button. The list can be any length. In order to get the book id I have set name="remove[${cartItem.bookId}]" but how do I get this value in a servlet? request.getParameter("remove") and request.getParameterValues("remove") returns null everytime.
<form method="post" action="removeBookFromCart">
<c:forEach var="cartItem" items="${sessionScope.cart.cartItems}">
<tr>
<td><c:out value="${cartItem.title}" /></td>
<td><input type="submit" name="remove[${cartItem.bookId}]" value="Remove"/></td>
</tr>
</c:forEach>
</form>
There are several solutions:
Use <button name="bookToRemove" value="${cartItem.bookId}" type="submit">Remove</button>. This, however, doesn't work as specified in IE6 and IE7 (at least).
Iterate through the parameters, find the one which starts with remove[, and extract the ID after that. You could use a simpler name, such as remove_${cartItem.bookId}
Create one form per cart item, instead of a global form, and use a hidden field to contain the book to remove.
The third way is probably the easiest one.
You could also use some JavaScript to initialize the value of a hidden field when a button is clicked, but this is not easier than the methods above, and requires JavaScript.
You have to use hidden parameters:
<input type="hidden" name="remove" value="${cartItem.bookId}"/>
Let the submit button be just this way:
<input type="submit" value="Remove"/>
EDIT:
Yes, you have to create a form element for each book:
<c:forEach var="cartItem" items="${sessionScope.cart.cartItems}">
<tr>
<td><c:out value="${cartItem.title}" /></td>
<td>
<form method="post" action="removeBookFromCart">
<input type="submit" value="Remove"/>
<input type="hidden" name="remove" value="${cartItem.bookId}"/>
</form>
</td>
</tr>
</c:forEach>
Is there a correct way to include multiple forms in a single table?
For example, I have 8 rows, four of them correspond to a single table, the other four correspond to a second. What would be the best way to do this? I know putting a table between TRs is invalid.
I think I found the solution for your problem, since I found myself on the same situation. Here is an example of what I did.
<form id="uno" name="uno" action="somescript.php" method="post">
<input type="hidden" id="myhidden" value="1">
</form>
<form id="dos" name="dos" action="anotherscript.php" method="post">
<input type="hidden" id="myhidden" value="2">
</form>
<table id="uniqueTable">
<tr>
<td><input form="uno" type="text" id="x_value" name="x_value" value="0.00"></td>
<td><input form="dos" type="text" id="x_anothervalue" name="x_anothervalue" value="0.00"></td>
</tr>
</table>
In this way, although there is only one table each of your inputs will belong to the form stated with the form="formName"
Hope it helps someone
- anakin
I don't think there is a standard way to do this. (which sucks)
You'll have to do something like give all the form elements in a row a prefix to indicate which row they are in, then detect which button was pressed. On the server you can then discard all the values that you aren't interested in.
edit: The information (name and value) of the buttons not pressed won't be submitted)
(Alternatively, if you use javascript you should be able to make work around to collect all the values from that row's inputs when the button is pressed.)