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

Select inside a form

function zmiana(ile){
var formObj = document.getElementById("dane").
while(formObj.childNodes.length > 3)
{
formObj.removeChild(formObj.lastChild);
}
for (i=1;i<=ile;i++){
pole=document.createElement("BR");
formObj.appendChild(pole);

a=document.createTextNode("Name of accompanying person #"+i+" ")
formObj.appendChild(a);

formObj.style.fontWeight='bold';

pole=document.createElement("input");
pole.type = "text";
pole.size="40";
pole.id="name"+i;
pole.name="name"+i;
formObj.appendChild(pole);
}
}

What should be in changed in line:

var formObj = document.getElementById("dane").

to make it work with something like this

<form name="dane">
<select name="accomp">

//instructions

</select>
</form>

Thanks.
Leszek


Dec 28 '05 #1
2 2681
Leszek wrote:
[...]
You'll probably bite the carpet when you have read the reponses to your
other posting because they address the problems with that code.
What should be in changed in line:

var formObj = document.getElementById("dane").

to make it work with something like this

<form name="dane">
Again, the `action' attribute is missing. The above is invalid HTML.
<select name="accomp">

//instructions
Again, HTML is not a programming language; it is a markup language.
</select>
</form>


var formObj = document.forms["dane"];

because there is no _ID_ `dane', there is a _name_.

However, you should rather try to pass a reference to the HTMLSelectElement
object (and then use its `form' property) or to the HTMLFormElement, with
`this'.
PointedEars
Dec 28 '05 #2

Uzytkownik "Thomas 'PointedEars' Lahn" <Po*********@web.de> napisal w
wiadomosci news:11*****************@PointedEars.de...

var formObj = document.forms["dane"];

I tried with this and it works but the text inputs made by function are now
outside frameset and below submit button
Here is code again:

function zmiana(ile){
var formObj = document.forms["dane"];
while(formObj.childNodes.length >3)
{
formObj.removeChild(formObj.lastChild);
}
for (i=1;i<=ile;i++){
pole=document.createElement("BR");
formObj.appendChild(pole);

a=document.createTextNode("Name of accompanying person #"+i+" ")
formObj.appendChild(a);

formObj.elements.style.fontWeight='bold';

pole=document.createElement("input");
pole.type = "text";
pole.size="40";
pole.id="$name"+i;
pole.name="$name"+i;
formObj.appendChild(pole);
}
}

<form name="dane" action="uzytkownik.php" method.post>
<fieldset>

<select name="accperson" onChange="zmiana(this.value)">
<?php
$accperson=0;
echo "<option value=\"$accperson\" selected >$accperson</option> \n";
for ($accperson=1;$accperson<=5;$accperson++){
echo "<option value=\"$accperson\">$accperson </option>\n";
}
?>
</select>
<p align="center">
<input type="submit" value="Wyslij dane" />
</p>
</fieldset>
</form0
Dec 28 '05 #3

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

Similar topics

17
by: Newbie | last post by:
Dear friends, I am having a hard time understanding how to use a SELECT CASE in ASP. I have used it in VB but never in ASP scripting. Scenerio: I have 2 textboxes on a form that I have to...
1
by: cgplays.com | last post by:
I have a select-pulldown at http://computergroupplays.com/fb-pres2.asp that changes the 3rd pulldown (Dbase) depending on what the user enters in the 2nd (Wk). My associate wants the values inside...
12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
5
by: Charles Lavin | last post by:
Hi -- I have a table cell in which is placed a <SELECT> tag. The drop-down box has an excessive amount of whitespace below it, forcing the cell to adjust its height to accommodate this extra...
2
by: jascraig | last post by:
Here's my dilemma. I'm working with a frameset with 3 frames (header,content,control). My control frame contains a select list with buttons for next and previous. When the next button is pushed...
2
by: Zlatko Matić | last post by:
Hello. How to reference selected values from a multi-select list box, as a criteria in a query ? Is it possible at all? Regards, Zlatko
2
by: KarlosSultana | last post by:
Hello to those who read this, this is my first ever post! I am currently getting very confused trying to put a <form> in a table-cell: Firstly I have a <div> styled with display:table -this...
2
by: artev | last post by:
if I insert a string null in a select, it change position; why? I insert value "" in 2nd 3th select; <style type="text/css"> td {border:2px solid pink;}; </style>
2
by: idontknow | last post by:
I have the following code : $form = "<head><title>:::Subjects:::</title></head> <script src='ajax_files/prototype.js'></script> <script src='ajax_files/getSecond.js'></script> <body>...
10
by: removeps-groups | last post by:
How to display table and select next to each other? <html> <body> <table border=1 style="display:inline-table"> <tr><td>Hello1</td></tr> <tr><td>Hello2</td></tr> <tr><td>Hello3</td></tr>...
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: 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?
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
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.