Connecting Tech Pros Worldwide Forums | Help | Site Map

Nested Forms: How can I escape them?

pk
Guest
 
Posts: n/a
#1: Sep 1 '05
Let me start off by mentioning that I'm not a web developer by any
means. I welcome any and all tips regarding code cleanliness and would
love to hear about any conventions that I'm breaking.

I have a page here that I've broken down to its simplest (that i know
of) elements so it is easier for you guys to follow along.

http://www.bigkaiser.com/phil/test.html

If you look closely, you'll see that I have an instance of nested
forms. I don't know how to get around this. The reason for this is
that I need the form that is nested inside, "myform", controls a
dynamic element in the greater form "kpt". When one chooses "Rough"
from the "Boring Type:" selection dropdown, another dropdown appears
below. I don't know how to get this behavior without creating a form.
I need the "kpt" form because it ultimately sends information to my SQL
Server backend and returns the query results. (This part was working
before I added the interior form.)

Now, what are my options? Please be verbose. :) Again, any comments
on code cleanliness are welcome, I'd like to learn clean code early on
rather than have to change my ways.

-pk


Martin Kurz
Guest
 
Posts: n/a
#2: Sep 1 '05

re: Nested Forms: How can I escape them?


pk schrieb:[color=blue]
> Let me start off by mentioning that I'm not a web developer by any
> means. I welcome any and all tips regarding code cleanliness and would
> love to hear about any conventions that I'm breaking.
>
> I have a page here that I've broken down to its simplest (that i know
> of) elements so it is easier for you guys to follow along.
>
> http://www.bigkaiser.com/phil/test.html
>
> If you look closely, you'll see that I have an instance of nested
> forms. I don't know how to get around this. The reason for this is
> that I need the form that is nested inside, "myform", controls a
> dynamic element in the greater form "kpt".[/color]

Why are you trying to nest forms? Forms must not contain other forms. There's
*no* reason for nesting forms.
[color=blue]
> When one chooses "Rough"
> from the "Boring Type:" selection dropdown, another dropdown appears
> below. I don't know how to get this behavior without creating a form.[/color]

Very simple: allmost in the same way you did, but without the inner form.
[color=blue]
> I need the "kpt" form because it ultimately sends information to my SQL
> Server backend and returns the query results. (This part was working
> before I added the interior form.)[/color]

well, no wonder :)
[color=blue]
> Now, what are my options? Please be verbose. :) Again, any comments
> on code cleanliness are welcome, I'd like to learn clean code early on
> rather than have to change my ways.
>
> -pk
>[/color]

Well, althoug I haven't understood the problem,

Just leave away the inner form, shouldn't change anything in functionality.

And if you want to get it working here's a hint: In the script, you chose the
dropdown by

document.getElementById("Finish").selectedIndex;

Well, that's OK so far, but the dropdown hasn't an ID:

<select name="Finish" onchange='able(this);'>

So change this to

<select name="Finish" id="Finish" onchange='able(this);'>

And you're fine (If you allready removed the inner form which is useless).

Greetings,

Martin
ASM
Guest
 
Posts: n/a
#3: Sep 1 '05

re: Nested Forms: How can I escape them?


pk wrote:[color=blue]
> Let me start off by mentioning that I'm not a web developer by any
> means. I welcome any and all tips regarding code cleanliness and would
> love to hear about any conventions that I'm breaking.[/color]

a form can't be in a table
a form can be in a cell
a form can contain a table
does a form can be in an other form ?
[color=blue]
> I have a page here that I've broken down to its simplest (that i know
> of) elements so it is easier for you guys to follow along.
>
> http://www.bigkaiser.com/phil/test.html
>
> If you look closely, you'll see that I have an instance of nested
> forms. I don't know how to get around this. The reason for this is
> that I need the form that is nested inside, "myform", controls a
> dynamic element in the greater form "kpt".[/color]

form 'myform' has any action
why selects (hidden and visible) can't be in main form kpt ?

[color=blue]
> When one chooses "Rough"
> from the "Boring Type:" selection dropdown, another dropdown appears
> below. I don't know how to get this behavior without creating a form.
> I need the "kpt" form because it ultimately sends information to my SQL
> Server backend and returns the query results. (This part was working
> before I added the interior form.)[/color]

What secondary select send, your SQL query must analyse it
Do your query relatively to those results

Why to not only use 'kpt' ?

<form action="insertselector.php" name="kpt" method="post"
target="stkdata" style="font-family:comic sans ms; color:#000;>
<table border="1" width="615">
<tr>
<td style="text-align:right" width=117>Boring Type:</td>
<td><select name="Finish"
onchange="var k = this.selectedIndex;
if(k==1) {
document.getElementById('BalStepDiv1').style.displ ay = 'inline';
}
else {
BalStepVal.selectedIndex = 0;
document.getElementById('BalStepDiv1').style.displ ay = '';
}
">
<option></option> <option>Rough</option>
<option>Finish</option>
</select>
<span id="BalStepDiv1" style="display:none;color:red">
Balance or Step :
<select name="BalStepVal">
<option></option>
<option>Balanced Cutting</option>
<option>Step Cutting</option> </select>
</span>
</td>
</tr>
<tr><td>...</td><td> ... </td></tr>
</table>

if 'Rough' is chosen
span 'BalStepDiv1' is displayed :
- text (balance)
AND
- select 'BalStepVal'
are shown

if not 'Rough' is not chosen,
- span 'BalStepDiv1' is none displayed : (text and select disappear)
- options of BalStepVal are set to first one (no text, no value)
your sql query must do something with this '0' or ''
or must not ? as you like.

Absolutly no need all those divs
while you use a table to arrange your elements
Absolutly no need all those font="face color ..." once is enough
use style insteed

--
Stephane Moriaux et son [moins] vieux Mac
Closed Thread


Similar JavaScript / Ajax / DHTML bytes