PDA

For continued disscussion on this topic : dynamically changing a form



dante
07-18-2001, 07:15 PM
G'Day all,

I've been trying to create a form that dynamically changes in response to an entry into a text box, with limited success.
One small problem - how can I get document.write to write to the same document & not to create a new one?
The form is here: http://www.vianet.net.au/~dante/xml/input_form.html
<mod edit>WARNING: this may crash Netscape browsers!!</edit>
Enter a new number (between 1 & 12) in the # of Authors text box then change the focus off it.
A new page is created with text boxes for each name component, repeated to the value entered.
I need it to fit into the original form.

Thanks,

dante

Vincent Puglia
07-18-2001, 08:16 PM
Hi dante & welcome to the inferno ...I mean forum :)

The short answer: you cannot.

The long answer: Once a page has completely loaded, document.write writes to a new page. If you want to keep all of the forms on the same page, you will need to use dHTML. That is, you can create a div/layer, write as many name forms as you like and then display it on the same page. If you would like to see what I mean, see the "Hiding Options in a Form" script/tutorial at my site.

The easy answer: create a pop Up window, write your fields to it and then, upon closing, send the data back to the main page.

Hope this helps some. If you need some more direction or you have some code questions, please post here.

Vinny

dante
07-19-2001, 06:06 PM
Thanks Vincent,

I had a look at your site & the tutorial.
Exactly what I was after.

I've created a new version of my form that almost achieves what I need it to - but I've got a problem in the coding that appends the new content to the form instead of completely replacing the old content.

The answer is prob'ly obvious - but I just can't grasp it right now.

Have a look: http://www.vianet.net.au/~dante/xml/input_form.html

It isn't really neccessary for it to work in anything other than IE5+ because I'm eventually converting it to work with XML & the only browser capable of that is IE5 with the new msxml3 parser installed.

Thanks,

dante


Abandon All Hope, Ye Who Enter Here...
Infernal Designs (http://www.vianet.net.au/~dante)

Vincent Puglia
07-20-2001, 04:22 AM
Hi dante & hope is what we circle round in the city -- 9 times, in fact :D,

That is because you are writing the data with the onload event handler. You have 2 choices:
1) place the appropriate information within the div; don't use the writeNames function with onLoad. Then when you expand it, the original info will be overwritten.
2) start your counter at 2 and write one less than asked for.

However, I would change the phrasing somewhat. My impression that you would expand the names by the number I entered -- not that the number I entered was the total

BTW: glad you like the site.

Vinny

dante
07-20-2001, 12:43 PM
Vincent,

I've replace the onLoad with html within the div - it now has one copy of the name entry table written in html.

It's still not working quite right yet though - try clicking on the button a few time to see what I mean.

What I need it to do is
wipe the contents of the div each time the button is clicked.
Then
replace the contents of the div with the new copies of the table.

eg:
enter value 4
click button
set div to blank
write name entry table times 4

enter value 12
click button
set div to blank
write name entry table times 12

I've tried doing this by adding to the code:
document.all.wholeName.innerHTML = wipeData;
With wipeData having an empty string value.
This seems to getting ignored - I don't know why...

To make things even more interesting I need to repeat this with another div under the Illustrator section of the form.

Thanks,

dante :confused:

mmi
07-20-2001, 03:06 PM
hey dante - there's some errors in your code

you close <HEAD> twice

is this
<!-- BODY -->being commented out as you are intending? - my codechecker seems to be saying you're opening BODY twice

is your script being commented out?

N won't like onLoad in TABLE or INPUT in TD
<td><input type="text" name="var name" size="47" maxlength="100" value=""></td>this is the cause of the crash, I guess :eek: - you want inputs inside forms

dante
07-20-2001, 04:17 PM
mmi,

Thanks for pointing out some errors I missed. I'm not sure what caused your browser to crash.:ques:

As I said in an earlier post:

"It isn't really neccessary for it to work in anything other than IE5+ because I'm eventually converting it to work with XML & the only browser capable of that is IE5 with the new MSXML3 parser installed. "

The <br /> is a self closed tag XHTML / XML compatible.

I'm in the habit of commenting the major section/tags of my code as I use Eversoft's First Page 2000 as a HTML editor & it highlights all commenting: making it very easy to find & replace things quickly.

As for the:
<td><input type="text" name="var name" size="47" maxlength="100" value=""></td> That's an old, old Netscape bug long since fixed.
There's one in the cell next to Post subject: on the reply page on this site.

Thanks,

dante

mmi
07-20-2001, 05:28 PM
hey dante
I'm not sure what caused your browser to crash.I'm fairly certain it's those FORMless TD inputs - I'm not so much suggesting you work for N4-compatiblity as asking that you show a little kindness to us old N4 geezers when posting URLs in town in the sense that clicking on your link to that page crashed all my N browsers and therefore represents a significant potential inconvenience to me - for example, I might lose an "unsaved" post I was writing :(

I don't think ANY N4 browser will be happy AT ALL with inputs that aren't contained in forms

also, I think you might want to look into the way N4 (N6?) interprets the specific characters (spacing?) you're using in your comment tags

I didn't mention
<br />:)

Vincent Puglia
07-20-2001, 10:57 PM
1) pass the div name to the repeater function; otherwise, you write the illustrator stuff to the author section

2) kill the do while; pass vNumVal to writenames, not i;

3) in writeNames, kill the "+" in the first line:
nameData = "<table border='0' align='center' width='340px'>";

4) make the trs & tds a loop and make appropriate ordernum to i changes:
for (i = 1; i <= ordernumber; i++)
{
nameData += "<input type='hidden' name='order_number_" + i + "' value='" + i + "' />";

5) kill the wipeData -- unnecessary -- you were appending everything see # 3 above

6) put the "visibility = " statement after the "innerHTML" statement. You want to show the changes, not what comes before the changes :)

7) when you pass the divName, you will have to make the following & other changes in the code:

document.all.wholeNames --> document.all[divName]


finally dante: I agree with mmi. Just because your code will appear in an intranet does not mean you should forego the rules of the road, so to speak. What works in today's IE may not and probably will not work in tomorrow's versions.

Vinny