CrazyEngineers Forum

Turn The Screws!

Open your eyes, look in front, look at the back, look at any angle and you will see something that is an engineer's creation.

Engineers have been making things possible that others could only imagine. It perfectly makes sense to have a common place for engineers from around the world where they can share ideas, innovate, & help each other. Engineers are eternal, with the younger at 62 & the youngest at 17, the CEan gang consists of working professionals, students, entrepreneurs, CEOs, professors, geeks & nerds.

Need we say more? Click Here To Join The Gang!
Navigation
Go Back   CrazyEngineers Forum > CE : Technical Discussions > Computer Science & IT Engineering
Reply

  #1 (permalink)
Old 19th July 2008, 08:57 AM
hbk
CE - Apprentice
 
I'm a Crazy Computers Engineer
Join Date: 12th June 2008
Posts: 36
Default dynamic form-field generation using javascript

hi guys.
i require some assistance of yours again.
what i want is this:
there is a form (say on page xyz.php) in which i have , say, 5 text-fields.
but i also hav a button. upon clicking whihc, i want another text-field to appear.
i do now want to use hidden fields as that would limit the number of EXTRA fields to a predefined value.
besides, i also hav to access the data [in each of the 5 fields as well as ALL the extra fields] on the "action page" of xyz.php (say abc.php)
javascript code shud do it but i m not able to figure it out....
could somebody pls help me wid -
1. dynamic text-box generation
2. accessing these fields on abc.php for insertion into MySQL database.
thx a lot...
__________________
2 ways to happines--->

1. Accept what you cannot change
2, Change what you cannot accept
hbk is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored links
  #2 (permalink)
Old 21st July 2008, 06:17 PM
CE - Regular Member
 
I'm a Crazy Electronics and Communication Engineer
Join Date: 19th March 2007
Location: Jeddah, Saudi Arabia
Posts: 69
Send a message via AIM to bayazidahmed Send a message via MSN to bayazidahmed Send a message via Yahoo to bayazidahmed
Default Re: dynamic form-field generation using javascript

let us suppose this is ur button in the BODY

<INPUT TYPE="BUTTON" VALUE="Testing" ONCLICK="javascript:btnTesting_Click();">

and create an extra empty DIV in the place where you want the textbox.
<DIV ID="testDiv"></DIV>

Now write the btnTesting_Click() in the HEAD

<SCRIPT TYPE="text/javascript">
function btnTesting_Click()
{
document.getElementById('testDiv').innerHTML = "<INPUT TYPE='TEXTBOX' NAME='txt'>"
}
</SCRIPT>


Example

<HTML>
<HEAD>
<SCRIPT TYPE="text/javascript">
function btnTesting_Click()
{
document.getElementById('testDiv').innerHTML = "<INPUT TYPE='TEXTBOX' NAME='txt'>";
}
</SCRIPT>
</HEAD>
<BODY>
<INPUT TYPE="BUTTON" VALUE="Testing" ONCLICK="javascript:btnTesting_Click();">
<DIV ID="testDiv"></DIV>
</BODY>
</HTML>
bayazidahmed is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored links
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +5.5. The time now is 08:11 PM.
Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Member comments are owned by the poster. Copyright © 2005-2008 CrazyEngineers.com. All rights reserved.Ad Management by RedTyger