Page 1 of 1
How to pass dynamic text box value to js
Posted: Wed Sep 05, 2007 7:16 am
by vinoth
hi all
In my project I want to pass multiple text box values to java script.
The textboxes are generated by dynamic is it possible to do that..
I need ur suggestions to achieve this
Posted: Wed Sep 05, 2007 7:28 am
by superdezign
"Pass them" to JavaScript? JavaScript has access to all content in the document. The simplest way to get the content of a textarea would be using the innerHTML property.
Posted: Wed Sep 05, 2007 7:32 am
by vinoth
I think u understood wrongly
I generate some textbox using forloop in php it will vary depending upon the user needs..
Now I have to calculate the sum of all text box value and print on another box
The calculation has done on OnBlur event.
Is it Possible?
Posted: Wed Sep 05, 2007 8:04 am
by superdezign
I don't believe I have misunderstood you at all. You simply place the JavaScript in the document after the textareas have been generated and get the information. Do you have any experience with the DOM?
I'm not sure why you can't handle this particular example in PHP since the data is generated by PHP.
Posted: Wed Sep 05, 2007 8:04 am
by themurph
Can you post the code you are working with?
Posted: Thu Sep 06, 2007 5:15 am
by vinoth
hi superdesign
Check this
Code: Select all
<? foreach($resultinvdetails->result() as $row)
{?>
<tr>
<td class="td18"><input type="text" class="price" name="color" value="<?=$row->OPTION_LIST?>"></td>
<td class="td19"><?=$resultmaininventory->WSELLING_PRICE?>/gross</td>
<td class="td20">Qty:<input type="text" id="1" name="name" size="1" value="0" onBlur="findtotal(this);"></td>
<td class="td21"><?if($row->OUT_OF_STOCK=='O'){echo "SOLD OUT";}else{echo "";}?></td>
</tr>
<?}?>
I want to display all the values entered into the text box.
Posted: Thu Sep 06, 2007 11:55 am
by califdon
vinoth wrote:Code: Select all
<? foreach($resultinvdetails->result() as $row)
{?>
<tr>
<td class="td18"><input type="text" class="price" name="color" value="<?=$row->OPTION_LIST?>"></td>
<td class="td19"><?=$resultmaininventory->WSELLING_PRICE?>/gross</td>
<td class="td20">Qty:<input type="text" id="1" name="name" size="1" value="0" onBlur="findtotal(this);"></td>
<td class="td21"><?if($row->OUT_OF_STOCK=='O'){echo "SOLD OUT";}else{echo "";}?></td>
</tr>
<?}?>
I want to display all the values entered into the text box.
As superdezign indicated, you could do that in PHP, just create another textbox and fill it with the content that you want.
If, for some other reason, you really need to do it after the page is loaded in the browser, you will need to add a
name= parameter for the other two
<td>s, just as you did with the first one, so that you can access them in Javascript, usually by using
getElementByName().