Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4096586
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:03:55+00:00 2026-05-20T20:03:55+00:00

I have some php code that is creating an html table. Within it I

  • 0

I have some php code that is creating an html table. Within it I have a form where I have different dropdown menus that have onChange events. I need to pass into the javascript function the table-row index. Is there any way to do this? If so could you please provide an example. Thank you!

My php code is listed below:

<?php
echo"
  <table id='inputTable'>
    <form id='trade' name='trade' method='post' action=''>
    <tr id = 'labelRow0' name = 'labelRow0' style='display:table-row'>
      <td>Spread Type</td>
      <td>Option/Future</td>
      <td>Year</td>
      <td>Month</td>
      <td>Strike</td>
      <td>Call/Put</td>
      <td>Buy/Sell</td>
      <td>Price</td>
      <td>Quantity</td>
      <td>Delta</td>
      <td>House</td>
    </tr>
    <tr id = 'inputRow0' name = 'inputRow0' style='display:table-row'>
      <td>
        <select onchange='testChanges(0)' name='spreadType[]' id='spreadType0'>
        <option value=''>
        <option value='Spread'>Spread
        <option value='Fly'>Fly
        <option value='Straddle'>Straddle
        <option value='Strangle'>Strangle
        <option value='Tree'>Tree
        <option value='Condor'>Condor
        <option value='Ladder'>Ladder
        </select>
      </td>
      <td>
        <select name='optionFuture[]' id='optionFuture0'>
        <option value=''>
        <option value='Option'>Option
        <option value='Future'>Future
        </select>
      </td>
      <td>
        <select name='year[]' id='year0'>
        <option value=''>
        <option value='Front'>Front
        <option value='Short'>Short
        <option value='Red'>Red
        <option value='Green'>Green
        <option value='Blue'>Blue
        <option value='Gold'>Gold
        </select>
      </td>
      <td>
        <select name='month[]' id='month0'>
        <option value=''>
        <option value='January'>January
        <option value='February'>February
        <option value='March'>March
        <option value='April'>April
        <option value='May'>May
        <option value='June'>June
        <option value='July'>July
        <option value='August'>August
        <option value='September'>September
        <option value='October'>October
        <option value='November'>November
        <option value='December'>December
        </select>
      </td>
      <td>
        <select name='strike[]' id='strike0'>
        <option value=''>
        <option value='100'>100
        <option value='99'>99
        <option value='98'>98
        <option value='97'>97
        <option value='96'>96
        </select>
      </td>
      <td>
        <select onchange='testChanges()' name='callPut[]' id='callPut0'>
        <option value=''>
        <option value='Call'>Call
        <option value='Put'>Put
        </select>
      </td>
      <td>
        <select name='buySell[]' id='buySell0'>
        <option value=''>
        <option value='Buy'>Buy
        <option value='Sell'>Sell
        </select>
      </td>
      <td>
        <input type='text' name='price[]' id='price0' size='9'/>
      </td>
      <td>
        <input type='text' name='quantity[]' id='quantity0' size='9'/>
      </td>
      <td>
        <input type='text' name='delta[]' id='delta0' size='9'/>
      </td>
      <td>
        <select onchange='testChanges()' name='house[]' id='house0'>
        <option value=''>
        <option value='001 - First Options'>001 - First Options
        <option value='020 - Bache'>020 - Bache
        <option value='033 - FC Stone'>033 - FC Stone
        <option value='Other'>Other
        </select>
      </td>
    </tr>
    <tr id = 'otherRow0' name = 'otherRow' style='display:none'>
      <td><input type='text' name='spreadFormation[]' id='spreadFormation0' size='9'/></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td><input type='text' name='otherHouse[]' id='otherHouse0' size='22'/></td>
    </tr>";

$baseLabel = 'labelRow';
$baseInput = 'inputRow';
$baseStr = 'otherRow';
$baseOptionFuture = 'optionFuture';
$baseYear = 'year';
$baseMonth = 'month';
$baseStrike = 'strike';
$baseCallPut = 'callPut';
$baseBuySell = 'buySell';
$baseSpreadType = 'spreadType';
$basePrice = 'price';
$baseQuantity = 'quantity';
$baseDelta = 'delta';
$baseHouse = 'house';
$baseSpreadFormation = 'spreadFormation';
$baseOtherHouse = 'otherHouse';

for ( $i = 1; $i < 20; $i++ ) 
{
  $labelId = $baseLabel.$i;
  $inputRow = $baseInput.$i;
  $otherId = $baseStr.$i;
  $optionFutureId = $baseOptionFuture.$i;
  $yearId = $baseYear.$i;
  $monthId = $baseMonth.$i;
  $strikeId = $baseStrike.$i;
  $callPutId = $baseCallPut.$i;
  $buySellId = $baseBuySell.$i;
  $spreadTypeId = $baseSpreadType.$i;
  $priceId = $basePrice.$i;
  $quantityId = $baseQuantity.$i;
  $deltaId = $baseDelta.$i;
  $houseId = $baseHouse.$i;
  $spreadFormationId = $baseSpreadFormation.$i;
  $otherHouseId = $baseOtherHouse.$i;

  echo"
    <tr id = $labelId name = $labelId style='display:none'>
      <td>Spread Type</td>
      <td>Option/Future</td>
      <td>Year</td>
      <td>Month</td>
      <td>Strike</td>
      <td>Call/Put</td>
      <td>Buy/Sell</td>
      <td>Price</td>
      <td>Quantity</td>
      <td>Delta</td>
      <td>House</td>
    </tr>
    <tr id = $inputRow name = $inputRow style='display:none'>
      <td>
        <select onchange='testChanges()' name='spreadType[]' id='spreadType0'>
        <option value=''>
        <option value='Spread'>Spread
        <option value='Fly'>Fly
        <option value='Straddle'>Straddle
        <option value='Strangle'>Strangle
        <option value='Tree'>Tree
        <option value='Condor'>Condor
        <option value='Ladder'>Ladder
        </select>
      </td>
      <td>
        <select name='optionFuture[]' id=$optionFutureId>
        <option value=''>
        <option value='Option'>Option
        <option value='Future'>Future
        </select>
      </td>
      <td>
        <select name='year[]' id=$yearId>
        <option value=''>
        <option value='Front'>Front
        <option value='Short'>Short
        <option value='Red'>Red
        <option value='Green'>Green
        <option value='Blue'>Blue
        <option value='Gold'>Gold
        </select>
      </td>
      <td>
        <select name='month[]' id=$monthId>
        <option value=''>
        <option value='January'>January
        <option value='February'>February
        <option value='March'>March
        <option value='April'>April
        <option value='May'>May
        <option value='June'>June
        <option value='July'>July
        <option value='August'>August
        <option value='September'>September
        <option value='October'>October
        <option value='November'>November
        <option value='December'>December
        </select>
      </td>
      <td>
        <select name='strike[]' id=$strikeId>
        <option value=''>
        <option value='100'>100
        <option value='99'>99
        <option value='98'>98
        <option value='97'>97
        <option value='96'>96
        </select>
      </td>
      <td>
        <select onchange='testChanges()' name='callPut[]' id=$callPutId>
        <option value=''>
        <option value='Call'>Call
        <option value='Put'>Put
        </select>
      </td>
      <td>
        <select name='buySell[]' id=$buySellId>
        <option value=''>
        <option value='Buy'>Buy
        <option value='Sell'>Sell
        </select>
      </td>
      <td>
        <input type='text' name='price[]' id=$priceId size='9'/>
      </td>
      <td>
        <input type='text' name='quantity[]' id=$quantityId size='9'/>
      </td>
      <td>
        <input type='text' name='delta[]' id=$deltaId size='9'/>
      </td>
      <td>
        <select onchange='testChanges()' name='house[]' id = $houseId>
        <option value=''>
        <option value='001 - First Options'>001 - First Options
        <option value='020 - Bache'>020 - Bache
        <option value='033 - FC Stone'>033 - FC Stone
        <option value='Other'>Other
        </select>
      </td>
    </tr>
    <tr id = $otherId name = $otherId style='display:none'>
      <td><input type='text' name='spreadFormation[]' id=$spreadFormationId size='9'/></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td><input type='text' name='otherHouse[]' id=$otherHouseId size='22'/></td>
    </tr>
  ";
}
echo "</table>
  <input id='submitButton' type='submit' name='submit' type='submit' value='submit' />
  </form>";
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T20:03:56+00:00Added an answer on May 20, 2026 at 8:03 pm

    Im use to Zend, so this is how I usually do it, isntead of echoing html, just type out the html, and then use <?for:?> syntax. Like the following.

     <table id='inputTable'>
        <form id='trade' name='trade' method='post' action=''>
        <tr id = 'labelRow0' name = 'labelRow0' style='display:table-row'>
          <td>Spread Type</td>
          <td>Option/Future</td>
          <td>Year</td>
          <td>Month</td>
          <td>Strike</td>
          <td>Call/Put</td>
          <td>Buy/Sell</td>
          <td>Price</td>
          <td>Quantity</td>
          <td>Delta</td>
          <td>House</td>
        </tr>
        <tr id = 'inputRow0' name = 'inputRow0' style='display:table-row'>
          <td>
            <select onchange='testChanges()' name='spreadType[]' id='spreadType0'>
            <option value=''>
            <option value='Spread'>Spread
            <option value='Fly'>Fly
            <option value='Straddle'>Straddle
            <option value='Strangle'>Strangle
            <option value='Tree'>Tree
            <option value='Condor'>Condor
            <option value='Ladder'>Ladder
            </select>
          </td>
          <td>
            <select name='optionFuture[]' id='optionFuture0'>
            <option value=''>
            <option value='Option'>Option
            <option value='Future'>Future
            </select>
          </td>
          <td>
            <select name='year[]' id='year0'>
            <option value=''>
            <option value='Front'>Front
            <option value='Short'>Short
            <option value='Red'>Red
            <option value='Green'>Green
            <option value='Blue'>Blue
            <option value='Gold'>Gold
            </select>
          </td>
          <td>
            <select name='month[]' id='month0'>
            <option value=''>
            <option value='January'>January
            <option value='February'>February
            <option value='March'>March
            <option value='April'>April
            <option value='May'>May
            <option value='June'>June
            <option value='July'>July
            <option value='August'>August
            <option value='September'>September
            <option value='October'>October
            <option value='November'>November
            <option value='December'>December
            </select>
          </td>
          <td>
            <select name='strike[]' id='strike0'>
            <option value=''>
            <option value='100'>100
            <option value='99'>99
            <option value='98'>98
            <option value='97'>97
            <option value='96'>96
            </select>
          </td>
          <td>
            <select onchange='testChanges()' name='callPut[]' id='callPut0'>
            <option value=''>
            <option value='Call'>Call
            <option value='Put'>Put
            </select>
          </td>
          <td>
            <select name='buySell[]' id='buySell0'>
            <option value=''>
            <option value='Buy'>Buy
            <option value='Sell'>Sell
            </select>
          </td>
          <td>
            <input type='text' name='price[]' id='price0' size='9'/>
          </td>
          <td>
            <input type='text' name='quantity[]' id='quantity0' size='9'/>
          </td>
          <td>
            <input type='text' name='delta[]' id='delta0' size='9'/>
          </td>
          <td>
            <select onchange='testChanges()' name='house[]' id='house0'>
            <option value=''>
            <option value='001 - First Options'>001 - First Options
            <option value='020 - Bache'>020 - Bache
            <option value='033 - FC Stone'>033 - FC Stone
            <option value='Other'>Other
            </select>
          </td>
        </tr>
        <tr id = 'otherRow0' name = 'otherRow' style='display:none'>
          <td><input type='text' name='spreadFormation[]' id='spreadFormation0' size='9'/></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td><input type='text' name='otherHouse[]' id='otherHouse0' size='22'/></td>
        </tr>";
    <?php 
    $baseLabel = 'labelRow';
    $baseInput = 'inputRow';
    $baseStr = 'otherRow';
    $baseOptionFuture = 'optionFuture';
    $baseYear = 'year';
    $baseMonth = 'month';
    $baseStrike = 'strike';
    $baseCallPut = 'callPut';
    $baseBuySell = 'buySell';
    $baseSpreadType = 'spreadType';
    $basePrice = 'price';
    $baseQuantity = 'quantity';
    $baseDelta = 'delta';
    $baseHouse = 'house';
    $baseSpreadFormation = 'spreadFormation';
    $baseOtherHouse = 'otherHouse';
    ?>
    
    <?php for ( $i = 1; $i < 20; $i++ ) :?>
    <?php
      $labelId = $baseLabel.$i;
      $inputRow = $baseInput.$i;
      $otherId = $baseStr.$i;
      $optionFutureId = $baseOptionFuture.$i;
      $yearId = $baseYear.$i;
      $monthId = $baseMonth.$i;
      $strikeId = $baseStrike.$i;
      $callPutId = $baseCallPut.$i;
      $buySellId = $baseBuySell.$i;
      $spreadTypeId = $baseSpreadType.$i;
      $priceId = $basePrice.$i;
      $quantityId = $baseQuantity.$i;
      $deltaId = $baseDelta.$i;
      $houseId = $baseHouse.$i;
      $spreadFormationId = $baseSpreadFormation.$i;
      $otherHouseId = $baseOtherHouse.$i;
    ?>
    
        <tr id = <?= $labelId ?> name = <?= $labelId  ?>style='display:none'>
          <td>Spread Type</td>
          <td>Option/Future</td>
          <td>Year</td>
          <td>Month</td>
          <td>Strike</td>
          <td>Call/Put</td>
          <td>Buy/Sell</td>
          <td>Price</td>
          <td>Quantity</td>
          <td>Delta</td>
          <td>House</td>
        </tr>
        <tr id = <?= $inputRow ?> name = <?= $inputRow ?>style='display:none'>
          <td>
            <select onchange='testChanges()' name='spreadType[]' id='spreadType0'>
            <option value=''>
            <option value='Spread'>Spread
            <option value='Fly'>Fly
            <option value='Straddle'>Straddle
            <option value='Strangle'>Strangle
            <option value='Tree'>Tree
            <option value='Condor'>Condor
            <option value='Ladder'>Ladder
            </select>
          </td>
          <td>
            <select name='optionFuture[]' id=<?= $optionFutureId ?>>
            <option value=''>
            <option value='Option'>Option
            <option value='Future'>Future
            </select>
          </td>
          <td>
            <select name='year[]' id=<?= $yearId ?>>
            <option value=''>
            <option value='Front'>Front
            <option value='Short'>Short
            <option value='Red'>Red
            <option value='Green'>Green
            <option value='Blue'>Blue
            <option value='Gold'>Gold
            </select>
          </td>
          <td>
            <select name='month[]' id=<?= $monthId ?>>
            <option value=''>
            <option value='January'>January
            <option value='February'>February
            <option value='March'>March
            <option value='April'>April
            <option value='May'>May
            <option value='June'>June
            <option value='July'>July
            <option value='August'>August
            <option value='September'>September
            <option value='October'>October
            <option value='November'>November
            <option value='December'>December
            </select>
          </td>
          <td>
            <select name='strike[]' id=<?= $strikeId ?>>
            <option value=''>
            <option value='100'>100
            <option value='99'>99
            <option value='98'>98
            <option value='97'>97
            <option value='96'>96
            </select>
          </td>
          <td>
            <select onchange='testChanges(<?= $i ?>)' name='callPut[]' id= <?= $callPutId ?>>
            <option value=''>
            <option value='Call'>Call
            <option value='Put'>Put
            </select>
          </td>
          <td>
            <select name='buySell[]' id=<?= $buySellId ?>>
            <option value=''>
            <option value='Buy'>Buy
            <option value='Sell'>Sell
            </select>
          </td>
          <td>
            <input type='text' name='price[]' id=<?= $priceId ?> size='9'/>
          </td>
          <td>
            <input type='text' name='quantity[]' id= <?= $quantityId ?> size='9'/>
          </td>
          <td>
            <input type='text' name='delta[]' id= <?= $deltaId ?> size='9'/>
          </td>
          <td>
            <select onchange='testChanges(<?= $i ?>)' name='house[]' id = <?= $houseId ?>>
            <option value=''>
            <option value='001 - First Options'>001 - First Options
            <option value='020 - Bache'>020 - Bache
            <option value='033 - FC Stone'>033 - FC Stone
            <option value='Other'>Other
            </select>
          </td>
        </tr>
        <tr id = $otherId name = $otherId style='display:none'>
          <td><input type='text' name='spreadFormation[]' id= <?= $spreadFormationId ?> size='9'/></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td><input type='text' name='otherHouse[]' id= <?= $otherHouseId ?> size='22'/></td>
        </tr>
    
    
    <? endfor; ?>
    
    
    
    </table>
    <input id='submitButton' type='submit' name='submit' type='submit' value='submit' />
     </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some PHP code that generates a calendar and then outputs html to
I have some PHP code that inserts a date into a table: INSERT INTO
I have some PHP code that generates dynamic tables of data on the fly.
I have some PHP code that is designed to make a spreadsheet with formulas
So I have some PHP code that looks like: $message = 'Here is the
I have php code that puts some values into an Array as follows: $hunter=addslashes($MessageArray[1]);
I have some setup code in my functions.php file that sets permalinks and adds
In PHP, say that you have some code like this: $infrastructure = mt_rand(0,100); if
I have some PHP code which allows me to sort a column into ascending
I have some PHP code which stores whatever is typed in a textbox in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.