473,549 Members | 2,408 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple Javascript Conundrum

Hi

Heres how the following code works. A user selects a number from a
listbox, and then javascript generates that many textboxes.
ie. If a user selects 5 from the listbox, then 5 text boxes will
appear. Problem is, javascript blanks the page out first. We really
need the textboxes to appear underneath the listbox, instead of
clearing the screen first.

<head>
<script type="text/javascript">
function CheckDropDown(v al)
{
var phil = parseInt(val);
document.write( "<table border=\'0\' width=\'100%\' id=\'table1\'
cellspacing=\'0 \' cellpadding=\'0 \' bgcolor=\'#FFE1 FF\'>");
for (i=1;i<=phil;i+ +)
{
this.document.w rite("<TR><TD width=\'200\'>B ox No: " + i +
"</td><td><input type=\'text\' name=\'Box"+i+" \'
size=\'20\'></td></tr>");
}
document.write( "</table>");
}
</script>
</head>
<body>
<form method="POST" action="--WEBBOT-SELF--" name="form1">
<!--webbot bot="SaveResult s" U-File="D:\Projec ts\City Car
Club\_private\f orm_results.csv " S-Format="TEXT/CSV"
S-Label-Fields="TRUE" -->
<p>&nbsp;</p>
<p>Is your partner a member? <select size="1" name="Partner_L ist"
onchange="Check DropDown(this.v alue);return false">
<option selected value="please select">please select</option>
<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="50000">5 0000</option>
</select></p>
<p>&nbsp;</p>
</form>
</body>

Oct 13 '05 #1
4 1425
JRS: In article <11************ **********@g47g 2000cwa.googleg roups.com>
, dated Thu, 13 Oct 2005 11:44:16, seen in news:comp.lang. javascript,
go****@budget-edi.co.uk posted :

Heres how the following code works. A user selects a number from a
listbox, and then javascript generates that many textboxes.
ie. If a user selects 5 from the listbox, then 5 text boxes will
appear. Problem is, javascript blanks the page out first. We really
need the textboxes to appear underneath the listbox, instead of
clearing the screen first.
You should read the newsgroup FAQ before asking simple questions.

var phil = parseInt(val);
This seems to be a case where the second parameter is not needed; but
var phil = +val
should do instead.
document.write( "<table border=\'0\' width=\'100%\' id=\'table1\'
cellspacing=\' 0\' cellpadding=\'0 \' bgcolor=\'#FFE1 FF\'>");


Code posted to News should be executable by copy'n'paste. Therefore,
don't let your posting agent line-wrap; do it yourself. To ease this,
indent by the reasonable minimum when showing structure. You can change
TAB into SPACE SPACE for posting.

You don't need, ISTM, to escape those ' characters with \ .

....

See FAQ section 4.15.

<FAQENTRY> 4.15 start : add something like "After a page is loaded, the
first use of document.write[ln] will clear it before writing.".

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Oct 14 '05 #2
Dr John Stockton said the following on 10/14/2005 9:07 AM:
JRS: In article <11************ **********@g47g 2000cwa.googleg roups.com>
, dated Thu, 13 Oct 2005 11:44:16, seen in news:comp.lang. javascript,
go****@budget-edi.co.uk posted :


<snip>
var phil = parseInt(val);

This seems to be a case where the second parameter is not needed; but
var phil = +val
should do instead.


Yet:

var phil = Number(val);

Is both "good enough" and self-documenting. It also does not use the
overloaded +

<snip>
See FAQ section 4.15.

<FAQENTRY> 4.15 start : add something like "After a page is loaded, the
first use of document.write[ln] will clear it before writing.".


document.write has nothing to do with dynamically changing the current
page. There should be something in the FAQ (or notes) about the improper
use of document.write but 4.15 isn't the right place.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 14 '05 #3
JRS: In article <hP************ ********@comcas t.com>, dated Fri, 14 Oct
2005 18:41:09, seen in news:comp.lang. javascript, Randy Webb
<Hi************ @aol.com> posted :
Dr John Stockton said the following on 10/14/2005 9:07 AM:
JRS: In article <11************ **********@g47g 2000cwa.googleg roups.com>
, dated Thu, 13 Oct 2005 11:44:16, seen in news:comp.lang. javascript,
go****@budget-edi.co.uk posted :
var phil = parseInt(val);

This seems to be a case where the second parameter is not needed; but
var phil = +val
should do instead.


Yet:

var phil = Number(val);

Is both "good enough" and self-documenting. It also does not use the
overloaded +


Unary + is not overloaded; and there is no harm in using an overloaded
operator. I expect your code uses binary +, in each sense, quite often.

<snip>
See FAQ section 4.15.

<FAQENTRY> 4.15 start : add something like "After a page is loaded, the
first use of document.write[ln] will clear it before writing.".


document.wri te has nothing to do with dynamically changing the current
page. There should be something in the FAQ (or notes) about the improper
use of document.write but 4.15 isn't the right place.


The first sentence is not true (so neither is the end of the second).
Often, people try to use document.write for that very purpose. When
they find that they have a problem, they may well search the FAQ for
"document.write ". At present, they'll find nothing helpful that way.
Grow up.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Oct 15 '05 #4
Dr John Stockton said the following on 10/15/2005 11:40 AM:
JRS: In article <hP************ ********@comcas t.com>, dated Fri, 14 Oct
2005 18:41:09, seen in news:comp.lang. javascript, Randy Webb
<Hi************ @aol.com> posted :
Dr John Stockton said the following on 10/14/2005 9:07 AM:

JRS: In article <11************ **********@g47g 2000cwa.googleg roups.com>
, dated Thu, 13 Oct 2005 11:44:16, seen in news:comp.lang. javascript,
go****@budge t-edi.co.uk posted :
var phil = parseInt(val);
This seems to be a case where the second parameter is not needed; but
var phil = +val
should do instead.
Yet:

var phil = Number(val);

Is both "good enough" and self-documenting. It also does not use the
overloaded +

Unary + is not overloaded; and there is no harm in using an overloaded
operator. I expect your code uses binary +, in each sense, quite often.


I said nothing about the "Unary +", I said the overloaded + operator.
And yes, it is overloaded.

Second, the code I posted is indeed what I said it to be. It is
self-documenting and (in your words) "good enough".

<snip>
See FAQ section 4.15.

<FAQENTRY> 4.15 start : add something like "After a page is loaded, the
first use of document.write[ln] will clear it before writing.".
document.writ e has nothing to do with dynamically changing the current
page. There should be something in the FAQ (or notes) about the improper
use of document.write but 4.15 isn't the right place.

The first sentence is not true (so neither is the end of the second).


It is 100% factually correct. You do not dynamically *change* a page
using document.write, you use document.write to dynamically *generate*
the page.
Often, people try to use document.write for that very purpose.
Then they need a good reference. Using the incorrect approach doesn't
make the approach part or even related to the solution other than maybe
a "what not to do" answer.
When they find that they have a problem, they may well search the FAQ for
"document.write ". At present, they'll find nothing helpful that way.


And that is because document.write has nothing to do with dynamically
changing a page. Your reasoning that if a person is wanting to
"dynamicall y change a page" that they would search for "document.write "
is seriously flawed. They search for what they are trying to do, not
what they think the solution might be.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
331
by: google | last post by:
Hi Heres how the following code works. A user selects a number from a listbox, and then javascript generates that many textboxes. ie. If a user selects 5 from the listbox, then 5 text boxes will appear. Problem is, javascript blanks the page out first. We really need the textboxes to appear underneath the listbox, instead of clearing...
4
1942
by: Jim Ford | last post by:
I have a single C file with the following code: int f2() { /* Blah-blah */ } int f1() { /* Blah-blah */
2
1205
by: Caladin | last post by:
I'm sure once someone answers this I'll feel really dumb. I'm a c++ programmer playing with c# an here's my conundrum I declare a class in the for public class Form1 : System.Windows.Forms.For class Class
4
1711
by: Jim Owen | last post by:
I am storing all my application data in the application cache. Anytime I have a method as part of an asp.net form, I need to access the objects in the cache. The only way I can think of to do this is to call something like: MyDataType LocalVar = (MyDataType)Cache; Which works fine, but I'm having to put that code at the top of every method...
26
11043
by: wardy | last post by:
Hi all, looking for a little bit of help.....I'm currently in the process of trying to understand the impact of the 508 guidelines on a web site that I am involved with, and I have a question surrounding the use of Javascript. The site currently relies on Javascript for navigating from page to page - I cannot find anything in the 508...
2
3164
by: subnunciation | last post by:
i know, this shouldnt be a conundrum right? one just shouldnt divide by zero. but this is suddenly happening *all over* my site. after chasing the error here and there, i simplified things down to: response.write cstr(4/2) response.end and i STILL get the error: Microsoft VBScript runtime error '800a000b' Division by zero
10
6060
by: ljlolel | last post by:
So.. I have a form that submits to an ASP.net site made in C-sharp. The ASP site is not mine, i do not have the server side code. When I submit from my form by pressing the Submit button, I get different results than when I use a javascript submit: form1.submit();. I think the javascript submit is working as it should, since I want the...
24
6298
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to have on his site, a Javascript Calculator for working out the cost of what they want, for example: 1 widget and 2 widglets = £5.00
2
1289
by: rjmlangley | last post by:
Hi Folks, I seem to have quite a conundrum here and I'm at my wits end. Essentially I have a HTML table where I'm trying to place a message at the top of the table should a value appear later in the table. My code is basically as follows... ... <table> <script language="javascript"> var myval = getmyval();
0
7467
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7736
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7982
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7500
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5110
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3514
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1961
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1079
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
783
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.