Proper way to include multiple forms in a single table - html

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.)

Related

Gatling: Get information out of HTML form

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.

Bulk delete with checkboxes and additional values

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.

Table with multiple rows doesn't work with forms in HTML

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.

Multiple Forms with same content boxes on one page

I'm looking for a solution to generate multiple forms on one page, that contain the same checkboxes and fields. For now, when I create those forms, even if I use different form names, all checkboxes with the same name get checked at the same time.
What I am trying to do is the following. I do have an events-list. Every event should have a form attached. Every form has some text and some checkboxes. But when I'm trying to check some boxes in my second form, it jumps to the first one (because of the same name of the checkbox).
<form method="post" name="form1">
<input type="checkbox" name="checkbox1" />
<input type="checkbox" name="checkbox2" />
</form>
<form method="post" name="form2">
<input type="checkbox" name="checkbox1" />
<input type="checkbox" name="checkbox2" />
</form>
Is there a way to get this working? Or do I have to use unique checkbox names, even if the formnames are unique? Which would make it more complex when I have a variable count of forms / events.
You can dynamically bind form elements i.e checkboxes. Don't include it in HTML code. This can be done with Jquery $.html() function to bind checkboxes to forms at runtime.
I guess this happens because form1 overrides form2 elements due to same names and id of checkboxes.
Or Try to use 4 different id of all checkboxes, and different id's of form names.
Hope it may work.
Happy Coding!
Atul Jindal

Intermixing HTML form and table

For a standard "add item" form page it is desirable to have two submit buttons: an "OK" button and a "cancel" button, where the former POSTs the form to one URL, and the latter GETs some other URL.
This obviously means that two separate FORMs are needed, and, if laid out with tables, the markup would go as follows:
<form action="add.html" method="post">
<table>
<tr>
<td>Enter data:</td><td><input type="text" name="data"/></td>
</tr>
</table>
<input type="submit" value="OK"/>
</form>
<form action="index.html" method="get">
<input type="submit" value="Cancel"/>
</form>
However, this would result in the two buttons being placed below each other. It would be desirable to have them placed side by side. The following works:
<form action="add.html" method="post">
<table>
<tr>
<td>Enter data:</td><td><input type="text" name="data"/></td>
</tr>
<tr>
<td><input type="submit" value="OK"/></td>
</form>
<form action="index.html" method="get">
<td><input type="submit" value="Cancel"/></td>
</tr>
</table>
</form>
But although I've seen it used on commercial websites, I guess it's not quite legal HTML.
So thus:
1) Since the second methods works, are there any good reasons for not using it?
2) Are there any better solutions?
EDIT: This was a silly question. The second method is unnecessary. Solution: add to the first method a CSS rule of:
form
{
display: inline;
}
You broke my mind.
There are many and varied problems with what you have here, but I'll start by pointing out that Cancel/Reset are not considered good things generally.
I'll follow that by pointing out that you could use CSS to style the buttons side by side in your first example, and follow that by pointing out that a simple type="button" could have any arbitrary script attached to it to do your cancel navigation, and follow that by the fact a simple anchor tag would be even more straightforward.
And I'm not going to mention the table, because that'll just start some trouble.
Don't use a second form. Wrap both buttons in the same form, and do something like this with the cancel button:
<input type="button" text="Cancel"
onclick="document.location.href='index.html';return false;" />
1) When you create a page using "legal HTML," you can have an expectation that what works in today's browsers will work in tomorrow's browsers, or in some other user agents that you might not have checked the site in. But in the example you've given, the degree to which different browsers agree on how to "fix" the HTML for display is much less certain. It adds a level of predictability to the how the page will display when "valid HTML" is used. Plus, who knows how a user agent such as a screenreader would describe the code in question.
2) Is using a regular anchor tag an option?
<td><input type="submit" value="OK"/></td>
<td> or Cancel</td>
Or you could use CSS to move a second form and its submit button up into the first form, but the specifics of this might be tricky.
Add a row to your table
<tr>
<td><input type="button" value="Cancel" onClick="window.location='./index.html'"/></td>
<td><input type="submit" value="OK" name="submit"/></td>
<tr>