How to pass dynamic text box value to js

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
vinoth
Forum Contributor
Posts: 113
Joined: Thu Aug 02, 2007 3:08 am
Location: India
Contact:

How to pass dynamic text box value to js

Post 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
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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.
vinoth
Forum Contributor
Posts: 113
Joined: Thu Aug 02, 2007 3:08 am
Location: India
Contact:

Post 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?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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.
User avatar
themurph
Forum Commoner
Posts: 76
Joined: Wed Apr 19, 2006 1:56 pm
Contact:

Post by themurph »

Can you post the code you are working with?
vinoth
Forum Contributor
Posts: 113
Joined: Thu Aug 02, 2007 3:08 am
Location: India
Contact:

Post 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.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post 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().
Post Reply