473,398 Members | 2,404 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,398 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 1263
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.