473,389 Members | 1,075 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,389 software developers and data experts.

Dynamic input problem - please help pulling my hair out for days

Hi,

I have the following script on my site but need to implement a select menu into the script as it would make it a lot tidier.

This script adds the required amount of fields selected by the user.

[HTML]<script language="JavaScript">

function createForm4(Sell_nliving) {
data = "";
inter = "'";
if (Sell_nliving < 6 && Sell_nliving > -1) {
for (i=1; i <= Sell_nliving; i++) {
if (i < 2) spaces=" ";
else spaces=" ";

data = data + "Lounge " + i + " :" + spaces
+ "<input type='checkbox' name=" + inter
+ "Sell_lounge" + i + inter + "'><br>";

data = data + "Dining Room " + i + " :" + spaces
+ "<input type='checkbox' name=" + inter
+ "Sell_dining" + i + inter + "'><br>";

data = data + "Conservatory " + i + " :" + spaces
+ "<input type='checkbox' name=" + inter
+ "Sell_conservatory" + i + inter + "'>";

data = data + "Attic " + i + " :" + spaces
+ "<input type='checkbox' name=" + inter
+ "Sell_attic" + i + inter + "'><br>";

data = data + "Study " + i + " :" + spaces
+ "<input type='checkbox' name=" + inter
+ "Sell_study" + i + inter + "'>";

data = data + "Games Room" + i + " :" + spaces
+ "<input type='checkbox' name=" + inter
+ "Sell_games" + i + inter + "'><br>";

data = data + "Reception Hall " + i + " :" + spaces
+ "<input type='checkbox' name=" + inter
+ "Sell_reception" + i + inter + "'>";

data = data + "Utility Room " + i + " :" + spaces
+ "<input type='checkbox' name=" + inter
+ "Sell_utility" + i + inter + "'><br>";

data = data + "Other " + i + " :" + spaces
+ "<input type='checkbox' name=" + inter
+ "Sell_other" + i + inter + "'><br>";

data = data + "Length " + i + " :" + spaces
+ "<input type='text' size=5 name=" + inter
+ "Sell_livingl" + i + inter + "'><br>";

data = data + "Width " + i + " :" + spaces
+ "<input type='text' size=5 name=" + inter
+ "Sell_livingw" + i + inter + "'><br>";

data = data + "Description <br>" + i + " :" + spaces
+ "<br><textarea size=5 name=" + inter
+ "Sell_kitdesc" + i + inter + "'></TEXTAREA><br>";

}


if (document.layers) {
document.layers.cust4.document.write(data);
document.layers.cust4.document.close();
}
else {
if (document.all) {
cust4.innerHTML = data;
}
}
}
else {
window.alert("You may only enter information for up to 7 Living Areas.");
}
}
// End -->



</script>

<input type="text" name="Sell_nliving" size="5" onchange="createForm4(counter.Sell_nliving.value); " />
</form>
[/HTML]
I then call the form using:

[HTML]<span id=cust4 style="position:relative;"></span>
[/HTML]
Instead of having all the room types as checkboxes, I would like them listed in a select menu as this would make it a lot neater for my customers.

Does anyone know how I can do this? Any help is much appreciated.

Thanks

Paul
Oct 12 '08 #1
1 1262
acoder
16,027 Expert Mod 8TB
To do that, you can either use a string as you're doing or the DOM methods, e.g. document.createElement(), setAttribute(), appendChild(). For the select element, you need a select element and option elements as children of that select element.

Note that the document.layers/document.all code is very old style (over 10 years old). To write cross-browser code, just use DOM methods or set the innerHTML of an element accessed using document.getElementById() which should work in all modern browsers.
Oct 12 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Mike | last post by:
Hey guys I am pulling my hair out on this problem!!!!! Any help or ideas or comments on how to make this work I would be grateful! I have been working on this for the past 4 days and nothing I do...
1
by: CanoeGuy | last post by:
I have been trying for the last two weeks to display a dynamic DataGrid. The data that I'm pulling from a SQL Server DB will have whole columns that will be either NULL or 0. I want to display...
1
by: rugrat | last post by:
Hi, I need to know how to create a dynamic menu-like the ones seen so often which will appear as page 12345 The current plans are to store the pages in a flat file system which would be something...
2
by: Salad | last post by:
I am having a problem with linking to FoxPro DOS tables in Access2000. Simply opening the tables are EXTREMELY slow. Let me tell you how make my connections to these tables. I could easily be...
5
by: MVaughn | last post by:
Hello, I've been reading this newsgroup for some time and have found all of you very helpful and knowledgable. So, first and foremost, thank you for all your help you've provided and don't even...
0
by: richard | last post by:
OK, Im finished pulling my hair out and now I need help. I have created a VB class file for my custom paging, in it I create a table with 2 rows, in the rows I have linkbuttons for first page,...
3
by: Mukesh | last post by:
sir, i am developing a database, which will store the users profile both personal and professional which includes the address, telephone, gender and etc. in my main table i have created a column...
4
by: Cigar2011 | last post by:
I will try to be short and to the point.(good Luck) I have a form written in HTML. I have a Mysql database. I am using a linux server and I would like to use php to write the following code: ...
31
by: DirtySnipe | last post by:
I have created a php form with dynamic drop down boxes in it which pull the options from a database. The boxes work fine and the data gets submitted fine but im having a problem getting the box to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...

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.