Hi I am strictly have problem in the script language: I am using the two dropdownlist box in php, my application developing by mvc when the page load the project dropdownlist option are loaded. but the user select the project from list and based on the project to load the module list in the dropdownlist.
I tried javascript to select the project value. and i do not know how to pass the client side variable value to server side variable. my code
view.php
<table class="row-fluid">
<tr>
<td><label for="taProj"><?php echo t('Project')?>:</label></td>
<td><select name="taProj" id="taProj" onchange= "checkField(this.value)">
<option value="" >-------------------------</option>
<?php foreach ($tap as $row){?>
<option value="<?php echo $row['proj_id']; ?>" ><?php echo $row['proj_name'];?></option>
<?php } ?>
</select></td>
<input type="hidden" name="pid" id="pid">
</tr>
<tr>
<td><label for="taModule"><?php echo t('Module Name')?>:</label></td>
<td><select name="taModule" id="taModule" >
<option value="" >-------------------------</option>
<?php //$myv = $_POST['modid'];
$myvar = print "<script type='text/javascript'>document.getElementById('pid')</script>";
foreach ($tam as $row){
if($row['proj_id'] == $myvar){?>
<option value="<?php echo $row['mod_id']; ?>" ><?php echo $row['mod_name'];?></option>
<?php } }?>
</select></td>
</tr>
script code:
function checkField(val){
document.getElementById("pid").value = val;
//alert(document.getElementById("pid").value);
}
the $tap and $tam from controller
My queries is, which method of script to use here and achieve this task. please suggest to me how to do this....
thanks Kumar