473,386 Members | 1,754 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,386 software developers and data experts.

'Form' and 'Div' - unable to divide page using DIV Tag

135 100+
I'm trying to use the DIV tag instead of the FORM tag which I'm currently using in my code to create a 'drop down list'. But I'm getting the ERROR: 'document.drop_list.locationID' is null or not an object.

How can I make the FORM tag to a DIV tag in the code below? What other changes do I need to do?:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.  
  4. <script>
  5. function addOption(selectbox,text,value)
  6. {
  7. var optn = document.createElement("OPTION");
  8. optn.text = text;
  9. optn.value = value;
  10. selectbox.options.add(optn);
  11. }
  12. </script>
  13.  
  14.  
  15. </head>
  16.  
  17.  
  18.  
  19. <body onLoad="addOption_list()";>
  20.  
  21. <FORM name="drop_list">
  22. Location:
  23. <SELECT NAME id="locationID">
  24. <option>--Location--</option></SELECT>
  25. </FORM>
  26.  
  27. <script>
  28. function addOption_list()
  29. {
  30.     var locate = new Array("England", "Wales", "Scotland", "Ireland"); 
  31.  
  32.         for (var i=0; i < locate.length;++i){
  33.  
  34.         addOption(document.drop_list.locationID, locate[i], locate[i]);
  35.         }
  36. }
  37. </script>
  38. <br></br>
  39. </body>
  40. </html>
Aug 13 '07 #1
4 3980
vee10
141 100+
I'm trying to use the DIV tag instead of the FORM tag which I'm currently using in my code to create a 'drop down list'. But I'm getting the ERROR: 'document.drop_list.locationID' is null or not an object.

How can I make the FORM tag to a DIV tag in the code below? What other changes do I need to do?:

<html>
<head>

<script>
function addOption(selectbox,text,value)
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}
</script>


</head>



<body onLoad="addOption_list()";>

<FORM name="drop_list">
Location:
<SELECT NAME id="locationID">
<option>--Location--</option></SELECT>
</FORM>

<script>
function addOption_list()
{
var locate = new Array("England", "Wales", "Scotland", "Ireland");

for (var i=0; i < locate.length;++i){

addOption(document.drop_list.locationID, locate[i], locate[i]);
}
}
</script>
<br></br>
</body>
</html>

hi ,

i have executed this code but i did not get any error and the values in dropdown list are present.
Aug 13 '07 #2
epots9
1,351 Expert 1GB
I'm trying to use the DIV tag instead of the FORM tag which I'm currently using in my code to create a 'drop down list'. But I'm getting the ERROR: 'document.drop_list.locationID' is null or not an object.

How can I make the FORM tag to a DIV tag in the code below? What other changes do I need to do?:

<html>
<head>

<script>
function addOption(selectbox,text,value)
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}
</script>


</head>



<body onLoad="addOption_list()";>

<FORM name="drop_list">
Location:
<SELECT NAME id="locationID">
<option>--Location--</option></SELECT>
</FORM>

<script>
function addOption_list()
{
var locate = new Array("England", "Wales", "Scotland", "Ireland");

for (var i=0; i < locate.length;++i){

addOption(document.drop_list.locationID, locate[i], locate[i]);
}
}
</script>
<br></br>
</body>
</html>
since your not doing anything with the form tag, why not hardcode it in?
[html]
<div name="drop_list">
Location:
<SELECT NAME id="locationID">
<option>--Location--</option></SELECT>
</div>
[/html]

but without the form tag u will be able to pass the results to a server-side script...unless u use AJAX.

good luck
Aug 13 '07 #3
epots9
1,351 Expert 1GB
u will also need to change this as well
Expand|Select|Wrap|Line Numbers
  1. addOption(document.getElementById("locationID"), locate[i], locate[i]);
  2.  
Aug 13 '07 #4
patelxxx
135 100+
Thank guys for your help, you answered my question!!!

Thanks again.
Aug 13 '07 #5

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

Similar topics

1
by: Michael Brennan-White | last post by:
If I submit my for using a get action the resulting page loads . If I use a post action I get an error page saying "The page cannot be found". I am calling the originating page!!! This happens...
13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
4
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I...
4
ak1dnar
by: ak1dnar | last post by:
Hi, I have created a PHP page that write down form data to mySQL table. Before i submit data I want to check the Input field, whether it has filled up or Not. the form should validate from the PHP...
10
by: neverquit | last post by:
hi , Iam Nagesh,Begineer in using Ajax,well i have been using ajax in application, i have faced a problem while placing the responseTEXT into the <div> tag positioned inside the <form> tag iam...
0
by: enrmpaga | last post by:
i'm using asp.c# to validate form and e-mail the results to my inbox but keep getting this error message: Compiler Error Message: CS0117: 'System.Web.UI.HtmlControls.HtmlForm' does not contain a...
0
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options...
1
by: selvialagar | last post by:
i have two select boxes in my form named month and year...when i selected these two things, there is a submit button called 'generate invoice'. when i click this, invoice report is generated as a...
1
by: chromis | last post by:
Hi, I'm having trouble fully implementing the edit section of a contact admin system, so far I have written the following: - Bean (Contact.cfc) - Data Access object (ContactDAO.cfc) - Gateway...
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...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.