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...

this is one type:

<script>
function Add()
{
</script>
<td width="300" ><input type="text" name="txt_prodid[]" class="border" size="25" /></td>
<td width="200" colspan="2"><input name="txt_proddescription[]" type="text" class="border" size="36" /></td>

<td width="200"><input type="text" name="txt_prodquantity[]" size="20" class="border" /></td>
<script>
}
</script>



<form name="pr_form" action="pr_add.php" method="post" onSubmit="return validateForm();">

<tr width="508" align="center">

<td colspan="2" align="right"><input name="Product" type="submit" value="Add Product" class="buttonSubmitMedium" onClick="Add();"></td>

The way I understand it, you want to have new textboxes appear due to an onClick event attached to a button. If that is incorrect, please clarify the post a bit.
To proceed with my understanding, let me preface: You will not need PHP to accomplish this task. A little CSS and Javascript will do the trick.

<html>
<!-- CSS Declaration -->
<head>
    <style type="text/css">

    /* Sets class for the text box  with a hidden property */
    .hide {
        display:none;
        }

    /* Sets class for the text box with a visible property */
    .show {
        display:block;
        }

    </style>
</head>

<body>

<input type="button" value="Show" onclick="document.getElementById('MyBox').className='show';" />
<input type="button" value="Hide" onclick="document.getElementById('MyBox').className='hide';" />

<br />
<br />

<!-- Hide and Show this DIV with the buttons above -->
<div id="MyBox" class="hide">
    <input type="text" name="TextBoxName" />
</div>
</body>
</html>

an ONCLICK-event based field-generation is exactly what i want.

thx 4 ur reply.

i shall try it in my app and get bak 2 u.

thx again.

thx a lot..

This article has been dead for over six months. Start a new discussion instead.