Welcome Guest, Not a member yet? Register   Sign In
using PHP id in Javascript
#1

[eluser]Byzs[/eluser]
Hello everybody, asking for a little help here, I'am trying to change an <option> value from Javascript using the id of the <select> which is dynamically generated by PHP.

this is my PHP code:

Code:
$modOr[0]="HCS";
$modOr[1]="CN";
$modOr[2]="CAD";
$modOr[3]="FG";
$modOr[4]="FOCSH";
$modOr[5]="FOCN";
$modOr[6]="FOAM";

for($m=0; $m<7; $m++)
{                                    
       echo("<select class='element select' id='curr".$modOr[$m]."'>");
}

and this is how I get access from the Javascript code:
Code:
document.getElementById("formName").currHCS.value = 1;


I have others <select> tags in the forms and they works fine when I try to access them from Javascript code...but their id is not dynamically generated, its just HTML.

I'am really stuck here, I don't if this is some CI problem or my code is wrong.
I added the id forum in the form_open like this:

Code:
$attributes = array('id' => 'formName');
echo form_open('',$attributes);

should I add the <select> id too?

Thanks, and sorry for the bad English ! Smile


Messages In This Thread
using PHP id in Javascript - by El Forum - 08-19-2012, 03:12 PM
using PHP id in Javascript - by El Forum - 08-21-2012, 01:26 AM
using PHP id in Javascript - by El Forum - 08-21-2012, 05:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB