Menu
Hi All!
I have seen a form made in InfoPath, and it has the ability to dynamically create rows in an order form (the user clicks a button and a popup menu gives them the option).
I was wondering if I can add that functionality to HTML form.
Has anyone done something like this before?
THANKS! any info would be appreciated!?
[i]Originally posted by sanjuT [/i]
[B]I was wondering if I can add that functionality to HTML form.
Has anyone done something like this before?[/B][/QUOTE]
[i]Originally posted by phpnovice [/i]And which do you think is better for accessibility reasons? ?
[B]How do you know they weren't using server-side code to add the rows? At any rate, as stated... To do that client-side would require DHTML (i.e., combining HTML with a client-side scripting language) -- which I have done. I have also done the server-side method, too. [/B][/QUOTE]
<i>
</i>inputEl = document.createElement("INPUT");
inputEl.setAttribute("id","userInput");
inputEl.setAttribute("value",'Input text' + id)
inputEl.setAttribute("name", 'name' + id);
<i>
</i>function addInput(obj)
{
tablebody = document.getElementById('mytbody'); // create obj reference
row = document.createElement("TR"); // create table row object
cell = document.createElement("TD"); // create table cell object
cell.appendChild(document.createTextNode('text' + id)); // create and add text node to cell
row.appendChild(cell); // add cell to row
// loop on the following section for multiple form fields
cell = document.createElement("TD"); // create table cell object
cell.setAttribute("id", 'value' + id); // set cell id
inputEl = document.createElement("INPUT"); // create form input object
// default input object type = "text"
inputEl.setAttribute("id", "userInput"); // set input id
inputEl.setAttribute("value", 'Input text' + id); // set input value
inputEl.setAttribute("name", 'name' + id); // set input name
cell.appendChild(inputEl); // add for input object to cell
row.appendChild(cell); // add cell to row
// end loop section
tablebody.appendChild(row); // add row to table
id++;
}
[i]Originally posted by phpnovice [/i]
[B]To document:
[/B][/QUOTE]
<i>
</i>function addInput(obj)
{
tablebody = document.getElementById('mytbody'); // create obj reference
row = document.createElement("TR"); // create table row object
cell = document.createElement("TD"); // create table cell object
cell.appendChild(document.createTextNode('text' + id)); // create and add text node to cell
row.appendChild(cell); // add cell to row
// loop on the following section for multiple form fields
cell = document.createElement("TD"); // create table cell object
cell.setAttribute("id", 'value' + id); // set cell id
inputEl = document.createElement("INPUT"); // create form input object
// default input object type = "text"
inputEl.setAttribute("id", "userInput"); // set input id
inputEl.setAttribute("value", 'Input text' + id); // set input value
inputEl.setAttribute("name", 'name' + id); // set input name
cell.appendChild(inputEl); // add for input object to cell
row.appendChild(cell); // add cell to row
// end loop section
tablebody.appendChild(row); // add row to table
id++;
}
[i]Originally posted by sanjuT [/i]
[B]why is the default input object type a textbox? can i have mult. elements? [/B][/QUOTE]
<i>
</i>inputEl = document.createElement("<INPUT TYPE=BUTTON>");
inputEl = document.createElement("<INPUT TYPE=FILE>");
inputEl = document.createElement("<INPUT TYPE=TEXT>");
inputEl = document.createElement("<INPUT TYPE=PASSWORD>");
inputEl = document.createElement("<INPUT TYPE=RADIO>");
inputEl = document.createElement("<INPUT TYPE=RESET>");
inputEl = document.createElement("<INPUT TYPE=SUBMIT>");
[i]Originally posted by phpnovice [/i]Since when is this propaganda or someone elses agenda? And since when is this not a technical answer? Our purpose is to help people here, correct? So why would you not give people the correct answer? Client side is incorrect for this application because of obvious accessibility reasons. I do not see how you could denigh that. Once again, how is this my agenda or propaganda?
[B]I believe that site's like this one should be for the purpose of providing technical answers. Period. I will not speak to propaganda nor to someone else's agenda. [/B][/QUOTE]
[i]Originally posted by PeOfEo [/i]
[B]...why would you not give people the correct answer?[/B][/QUOTE]
[i]Originally posted by phpnovice [/i]Phpnovice, this is no hyjacking a thread. You fail to realize that me suggesting a server side language [b]is a technical answer[/b] even though I am not posting code. Just because I am trying to get the point accross that server side is a more accessible solution, which is a proven fact and very logical, does not mean that I am trying to get him to do this because of my own agenda (when you use a word like agenda it has a connotation that I would gain from this). Why don't you stop using charged words and stop ignoring suggestions and work towards accessibility? How is my answer wrong, you said you have reasons? Honestly, doing this with javascript is wrong because [b]it will fail for a % of the internet[/b]. For every 100 hits, statistically speaking, this form is going to fail for around 5 of them. Now ask yourself, would you want parts of your site, essential parts to fail for those people?
[B]To give the kind of answer you're lobbying for, requires a judgement call. Who decides what is the "correct" answer? Those who try to decide such things for others are subject to propaganda and to sombody else's agenda. Every lobbyist has an agenda and the lobbyist's tool is propaganda.
Thus, I will stick to giving the technical answer for the question actually asked -- and leave the judgement calls up to the person implementing the technical answers given. There are oh so many reasons I could give you as to why your answer is the wrong one. However, you have already made your judgement call and are, thus, biased to not truly hear other views.
Now, why don't you leave off hijacking this person's thread for your own agenda? [/B][/QUOTE]
[i]Originally posted by PeOfEo [/i]
[B]How about you start considering and being more open to the comments and suggestions by other members on this forum instead of shooting them down as something that is not technical or hijacking, or even just being sarcastic about it? It is extremely rude.[/B][/QUOTE]
[i]Originally posted by phpnovice [/i]I am being considerite to the op. Also, your code was wrong, that is a criticism, and should not be taken as an insult. My calling you wrong is not the same as say me calling you stupid. Me calling you wrong and telling you what would make it correct is me trying to fix a problem.
[B]Talk about who is being rude and who is shooting whom down... [b][u][i]You[/i][/u][/b] are the jerk that jumped in on my other thread and stated right off the bat that my example was "wrong". That is neither a comment nor a suggestion. That is an [u]accusation[/u] based on a judgement call using your own agenda and propaganda. There is [u][i]nothing[/i][/u] technical about such a statement. When [b][u][i]you[/i][/u][/b] learn how to talk considerately to people, [b][u][i]then[/i][/u][/b] they will be a little more open minded to you.[/b][/quote]
[b]Propoganda? How so, how is this my agenda or propoganda? How would I benefit from you giving me an answer. The reason I asked you is because you said you have done this both server side and client side. I want to get the point accross that this done client side [b]will[/b] be inaccessible for users. That is why I asked you, because I feel it is absolutly neccessary that thing be done right. You are the one who does not have the facts straight if you cannot see obvious accessibility issues.
In [b][u][i]this[/i][/u][/b] thread, again, you weren't making either a comment or a statement. You tried to elicit a response from me that was in line with your agenda and in support of your propaganda. My response was that I won't lower myself to that level. You didn't like that, so now you're trying to accuse me of not being open minded. I think you need to get your facts straight. [/B][/QUOTE]
[i]Originally posted by PeOfEo [/i]
[B]Phpnovice, this is no hyjacking a thread. You fail to realize that me suggesting a server side language [b]is a technical answer[/b] even though I am not posting code. Just because I am trying to get the point accross that server side is a more accessible solution, which is a proven fact and very logical, does not mean that I am trying to get him to do this because of my own agenda (when you use a word like agenda it has a connotation that I would gain from this). Why don't you stop using charged words and stop ignoring suggestions and work towards accessibility? How is my answer wrong, you said you have reasons? Honestly, doing this with javascript is wrong because [b]it will fail for a % of the internet[/b]. For every 100 hits, statistically speaking, this form is going to fail for around 5 of them. Now ask yourself, would you want parts of your site, essential parts to fail for those people?
How about you start considering and being more open to the comments and suggestions by other members on this forum instead of shooting them down as something that is not technical or hijacking, or even just being sarcastic about it? It is extremely rude.
sanjuT, what server side languages do you have available, I might be able to help you do this server side if you wish. [/B][/QUOTE]
[i]Originally posted by PeOfEo [/i]Accessibility issues isn't the point. If they were, the person asking the question would have asked for a solution that takes into account accessibility issues. You and Charles (to name only two) should stop applying ruler-sized laws with a 12-foot two-by-four. Those laws only apply in certain instances. THEY DO NOT APPLY TO EVERYONE THAT CREATES A WEBSITE.
[B]...if you cannot see obvious accessibility issues. [/B][/QUOTE]
[i]Originally posted by simpson97 [/i]
[B]Heres an example of multiple tags:
http://www.simpsonscripts.com/enigma/exercize.html
Bob [/B][/QUOTE]
[i]Originally posted by phpnovice [/i]As I posted in the other thread, they do. Accessibility is everything. I do not understand why you would want your site not to work for some of your users....
[B]Accessibility issues isn't the point. If they were, the person asking the question would have asked for a solution that takes into account accessibility issues. You and Charles (to name only two) should stop applying ruler-sized laws with a 12-foot two-by-four. Those laws only apply in certain instances. THEY DO NOT APPLY TO EVERYONE THAT CREATES A WEBSITE. [/B][/QUOTE]
[i]Originally posted by PeOfEo [/i]
[B]As I posted in the other thread, they do.[/B][/QUOTE]
[i]Originally posted by sanjuT [/i]okay, I know asp so let me answer this with it. So is the user going to select an option that will dictate the number of rows added?
[B]Hi All!
I have seen a form made in InfoPath, and it has the ability to dynamically create rows in an order form (the user clicks a button and a popup menu gives them the option).
I was wondering if I can add that functionality to HTML form.
Has anyone done something like this before?
THANKS! any info would be appreciated!? [/B][/QUOTE]
[i]Originally posted by PeOfEo [/i]
[B]okay, I know asp so let me answer this with it. So is the user going to select an option that will dictate the number of rows added?
it is going to be something like this, after the user selects the option they are going to hit a submit button in a form with a similar action to this
<form action="yourpage.asp" method="post">
and the page will be resent and the script will be like this
inputname=Request.Form("inputname")
and then it is going to take that input be the value a loop will loop to to print out the feilds, each with a name that will change with the value of the loop's counting variable. If you would like to do it this way I can provide some actual code for it. [/B][/QUOTE]
[i]Originally posted by PeOfEo [/i]
[B]I will have to work on it a little later but I can. I guess you will need the code for page 1 and the code for the loop to print the extra inputs? [/B][/QUOTE]
<i>
</i><body>
<form action="yourform.asp" method="post">
<select name="number">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
<input type="submit" value="Submit"/>
</form>
</body>
<i>
</i><body>
<table>
<%
dim numrows
numrows=Request.Form("number")
dim i
For i=1 to numrows
%>
<tr><td><input type="text" name="usernum<% response.write(i) %>" size="20"></td></tr>
<%
Next
%>
</table>
</body>
[i]Originally posted by PeOfEo [/i]
[B]Basically your select number page is pretty simple, it can just be a plain html page if you like. Here is some code
<i>
</i><body>
<form action="yourform.asp" method="post">
<select name="number">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
<input type="submit" value="Submit"/>
</form>
</body>
[/B][/QUOTE]
This page is not Valid -//W3C//DTD HTML 4.01 Strict//EN!
Below are the results of attempting to parse this document with an SGML parser.
Line 11, column 21: document type does not allow element "SELECT" here; missing one of "P", "H1", "H2", "H3", "H4", "H5", "H6", "PRE", "DIV", "ADDRESS" start-tag
<select name="number">
The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.
One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").
✉
Line 19, column 35: document type does not allow element "INPUT" here; missing one of "P", "H1", "H2", "H3", "H4", "H5", "H6", "PRE", "DIV", "ADDRESS" start-tag
<input type="submit" value="Submit"/>
The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.
One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").
✉
Line 19, column 36: character data is not allowed here
<input type="submit" value="Submit"/>
You have used character data somewhere it is not permitted to appear. Mistakes that can cause this error include putting text directly in the body of the document without wrapping it in a container element (such as a <p>aragraph</p>) or forgetting to quote an attribute value (where characters such as "%" and "/" are common, but cannot appear without surrounding quotes).
✉
Line 20, column 6: end tag for "FORM" which is not finished
</form>
Most likely, You nested tags and closed them in the wrong order. For example <p><em>...</p> is not acceptable, as <em> must be closed before <p>. Acceptable nesting is: <p><em>...</em></p>
Another possibility is that you used an element (e.g. 'ul') which requires a child element (e.g. 'li') that you did not include. Hence the parent element is "not finished", not complete.
✉ [/quote]
[i]Originally posted by phpnovice [/i]Wow, phpnovice, you are missing why I chriticized it in the first place. I did because you are using javascript incorrectly. In the other thread your script would have made the contents completely inaccessible for some of your users, in this thread your script would hace caused the form to fail for some of your users.
[B]The "big talker" can't even supply valid HTML himsmelf. What a joke you are. You have a lot of gaul to criticize others with your talk of valid HTML and you can't even supply same yourself.
By the way... Don't even try to use any excuses along the lines of this being only a BODY section and, therefore, the standard for some lower version of HTML may be applied to it. The markup I supplied in the other thread (which you had the gaul to criticize) was also an incomplete page which did not indicate the version of HTML. So, have the decency (if you have any -- which I doubt you do) to apply the same standards to yourself as you apply to others. [/B][/QUOTE]
[i]Originally posted by PeOfEo [/i]
[B]you are missing why I chriticized it in the first place. I did because you are using javascript incorrectly.[/B][/QUOTE]
[i]Originally posted by PeOfEo [/i]
[B]PHPnovice has done the following:
[list]
[*]Had objects set to display:none and this is altered with javascript, users without javascript cannot get the content [*]there is not a doc type in sight in any of his examples. Without a doc type the browser is in quirks mode. [*]inaccessible attribute for a list type="I", type is now deprecated and has been replaced by a css equiv [*]lack of type tag for a style tag. The style tag is not reserved just for css so this leaves the browser guessing. [*]lack of type tag for javascript, again the browser is guessing.
[/list]
Those are just a few errors I would like to point out that exist in this thread alone. [/B][/QUOTE]
[i]Originally posted by PeOfEo [/i]
[B]If you still believe that I am wrong why don't you go ask some of the forum's other senior members to have a look see at the threads and be the judge.[/B][/QUOTE]
[i]Originally posted by PeOfEo [/i]
[B]It seems to me that you just have a certain arrogance about you and cannot stand to have someone else pointing out things that need to be changed.[/B][/QUOTE]
[i]Originally posted by PeOfEo [/i]
[B]Also, it looks to me like you do not really know why daveclark was banned.[/B][/QUOTE]
[i]Originally posted by PeOfEo [/i]
[B]I am going to say this once novice, keep a civil tongue. Keep calling members (like myself and charles) names and you too will be banned.[/B][/QUOTE]
[i]Originally posted by DaveSW [/i]
[B]On the other hand, you work with what technologies you have available.[/B][/QUOTE]
[i]Originally posted by DaveSW [/i]
[B]Please ensure any further posts are back on topic, or this thread will have to be closed, which hardly seems fair on the original poster.[/B][/QUOTE]
[i]Originally posted by PeOfEo [/i]
[B]Basically your select number page is pretty simple, it can just be a plain html page if you like. Here is some code
<i>
</i><body>
<form action="yourform.asp" method="post">
<select name="number">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
<input type="submit" value="Submit"/>
</form>
</body>
The form page would have to be asp
<i>
</i><body>
<table>
<%
dim numrows
numrows=Request.Form("number")
dim i
For i=1 to numrows
%>
<tr><td><input type="text" name="usernum<% response.write(i) %>" size="20"></td></tr>
<%
Next
%>
</table>
</body>
If you notice the name is usernum1, 2, 3, and so on. I have the name incrimenting so you do not have duplicate feilds and have problems when you try to request that value.
Now, if you want to use that number the user selected later you can at the top of the asp page drop that into the session temporarily or something to be used on this page and other pages. You can add up those form values client side to show the user, but It would be easy and safe to also do that server side when you process this form.
You can see these nuggets of code in action on my server:
http://quasi-ke.servebeer.com/sampleaps/selectnum.asp [/B][/QUOTE]
[i]Originally posted by sanjuT [/i]
[B]...so i will name each related field a similar name, but differentiated by a 1, 2, etc. at the end....[/B][/QUOTE]
[i]Originally posted by sanjuT [/i]The server that was running on is my pc, I use it as a testing box. I keep it on all night generally but I usually have it turned off when I am in class or at work. ?
[B]THANKS Peofeo!!! I will give that a try. i have about 6 fields per row, so i will name each related field a similar name, but differentiated by a 1, 2, etc. at the end. i will post what i come up with.
BTW, is it easier to do this server-side, or just that it is the correct way to do it? also, i get a connection time-out when trying to view the page u posted. [/B][/QUOTE]
<i>
</i><form name="yourform.asp">
<table>
<%
dim numrows
numrows=Request.Form("number")
dim i
For i=1 to numrows
%>
<table title="Itemized List Entry" style="border-right:medium none;table-layout:fixed;border-top:medium none;font-size:10pt;border-left:medium none;width:545px;border-bottom:medium none;font-family:Verdana;border-collapse:collapse;word-wrap:break-word" border=1 width="606" ID="Table1">
<colgroup> <col style="width:45px" width=45> <col style="width:161px" width=161>
<col style="width:102px" width=102> <col style="width:71px" width=71> <col style="width:73px" width=73>
<col style="width:93px" width=93></colgroup> <tbody valign=top>
<tr style="min-height:21px">
<td style="color:black;background-color:#ebf0f9;border-right:#517dbf 1pt solid;padding-right:3px;border-top:#000000 2pt solid;padding-left:3px;padding-bottom:3px;vertical-align:middle;border-left:#517dbf 1pt solid;padding-top:3px;border-bottom:#000000 1pt" rowspan=2 width=45>
<div><font face=Verdana size=1><strong>Item </strong></font><font face=Verdana size=1><strong>#</strong><%response.write(i)%></font></div>
</td>
<td style="color:black;background-color:#ebf0f9;border-right:#517dbf 1pt solid;padding-right:3px;border-top:#000000 2pt solid;padding-left:3px;padding-bottom:3px;vertical-align:middle;border-left:#517dbf 1pt solid;padding-top:3px;border-bottom:#517dbf 1pt solid" colspan=4>
<div><font face=Verdana size=1><strong>Description: </strong><input type="text" name="description<%response.write(i)%>" size="60"></font></div>
</td>
<td style="color:black;background-color:#ebf0f9;border-right:#517dbf 1pt solid;padding-right:3px;border-top:#000000 2pt solid;padding-left:3px;padding-bottom:3px;vertical-align:middle;border-left:#517dbf 1pt solid;padding-top:3px;border-bottom:#000000 1pt" rowspan=2 width=101>
<div align=center><font face=Verdana size=1><strong>Total: </strong><input type="text" name="total<%response.write(i)%>" size="5"></font></div>
</td>
</tr>
<tr style="min-height:21px">
<td style="color:black;background-color:#ebf0f9;border-right:#517dbf 1pt solid;padding-right:3px;border-top:#517dbf 1pt solid;padding-left:3px;padding-bottom:3px;vertical-align:middle;border-left:#517dbf 1pt solid;padding-top:3px;border-bottom:#000000 1pt" width=177>
<div><font face=Verdana size=1><strong>Part Number: </strong><input type="text" name="partno<%response.write(i)%>" size="10"></font></div>
</td>
<td style="color:black;background-color:#ebf0f9;border-right:#517dbf 1pt solid;padding-right:3px;border-top:#517dbf 1pt solid;padding-left:3px;padding-bottom:3px;vertical-align:middle;border-left:#517dbf 1pt solid;padding-top:3px;border-bottom:#000000 1pt" width=110>
<div><font face=Verdana size=1><strong>Quantity: </strong><input type="text" name="quantity<%response.write(i)%>" size="10"></font></div>
</td>
<td style="color:black;background-color:#ebf0f9;border-right:#517dbf 1pt solid;padding-right:3px;border-top:#517dbf 1pt solid;padding-left:3px;padding-bottom:3px;vertical-align:middle;border-left:#517dbf 1pt solid;padding-top:3px;border-bottom:#000000 1pt" width=75>
<div><font face=Verdana size=1><strong>UOM: </strong><input type="text" name="uom<%response.write(i)%>" size="5" ID="Text2"></font></div>
</td>
<td style="color:black;background-color:#ebf0f9;border-right:#517dbf 1pt solid;padding-right:3px;border-top:#517dbf 1pt solid;padding-left:3px;padding-bottom:3px;vertical-align:middle;border-left:#517dbf 1pt solid;padding-top:3px;border-bottom:#000000 1pt" width=77>
<div><font face=Verdana size=1><strong>Unit Price: </strong><input type="text" name="price<%response.write(i)%>" size="5" ID="Text1"></font></div>
</td>
</tr>
</table>
<%
Next
%>
</table>
</form>
0.1.9 — BETA 5.17