Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: add more question


Message #1 by "suzila" <smay642@h...> on Tue, 30 Jul 2002 04:29:17
Hi,

I sometimes read the questions on this list - and then I set the questi
on
as a test of my own skills :-)
So here is my soloution - basic one - to your needs :-)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<meta name=3D"GENERATOR" content=3D"Microsoft Visual Studio.NET 7.0">
<meta name=3D"vs_targetSchema" content
=3D"http://schemas.microsoft.com/intellisense/ie5">
<script language=3D"javascript">
<!--
var oQuestion       =3D document.createElement('textarea');
oQuestion.rows =3D '3';
oQuestion.cols =3D '60';
oQuestion.style.width    =3D '400px';

var iQuesCount =3D 0;
var oInsertHere     =3D '';
function addQuestion() {
     if (iQuesCount-1>=3D0) {
          var oLastQuestion        =3D document.getElementById('q'
+(iQuesCount-1));
          if (oLastQuestion.value=3D=3D'') {
               alert('Please fill out the last question\nbefore adding 
a
new one...');
               oLastQuestion.focus();
               return (false);
          }
     }
     var oCurrentQuestion     =3D oQuestion.cloneNode(true);
     oCurrentQuestion.name    =3D 'q'+iQuesCount;
     oCurrentQuestion.id      =3D oCurrentQuestion.name;
     if (oInsertHere=3D=3D'') {
          oInsertHere                         =3D document.getElementBy
Id
('insertHere');
     }
     oInsertHere.appendChild(oCurrentQuestion);
     oCurrentQuestion.focus();
     iQuesCount++;
}
//-->
</script>

</head>
<body>
     <form action=3D"myaction" method=3D"post" id=3D"myform" style=3D"W
IDTH:
400px;">
          <div id=3D"insertHere" style=3D"padding-left: 3px; padding-to
p: 2px;
font-size: 10pt; color: white; font-family: Sans-Serif; background-colo
r:
#000066">Your questions:</div>
          <div align=3D"right" style=3D"background-color: white; border
-top:
1px solid black; width: 400px"><input type=3D"button" value=3D"Add ques
tion"
onclick=3D"addQuestion()" id=3D"Button1" name=3D"Button1"><input type=3D
"button"
onclick=3D"sendQuestions()" value=3D"Submit" id=3D"Button2" name=3D"But
ton2"></div>
     </form>
</body>
</html>

Med venlig hilsen

Sten Hougaard
EDB Gruppen
Application developer/web-designer
e-business solutions
Bredskifte All=E9 15
DK-8210 =C5rhus V
Tlf. +xx xx xx xx xx
Fax +xx xx xx xx xx
Mobil +xx xx xx xx xx
E-mail: stg@e...


                                                                       
                                           
                    "suzila"                                           
                                           
                    <smay642@h...       To:     "JavaScript HowTo" <ja
vascript_howto@p...>               
                    il.com>              cc:                           
                                           
                                         Subject:     [javascript_howto
] add more question                        
                    30-07-2002                                         
                                           
                    06:29                                              
                                           
                    Please respond                                     
                                           
                    to "JavaScript                                     
                                           
                    HowTo"                                             
                                           
                                                                       
                                           
                                                                       
                                           




hi ,

my project is about build a questionnaire, i have a form where user can

insert their question,how could i do to make
when user click "add question" button , another form input appears
where they can submit multiple questions on the same form


---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogra
mme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogra
mme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogra
mme
r-20





  Return to Index