0

I need to modify some code in cakePHP and the last thing that is holding me still is my inability to get current value from input form and send it to my jquery script.

The forms look like this:

   <?php echo $this->Form->input('country', array('options' => $countriesOption, 'onchange' => 'getHotels(this.value, $(\'showSingleInput\').checked);', 'style' => 'margin: 10px;', 'div' => false, 'label' => false, 'error' => 'false', 'hiddenField' => false, 'id' => 'countryInput')); ?>
   <?php 
   if($regionOption != null){
        echo $this->Form->input('region', array('options' => $regionOption, 'onchange' => 'getHotelsInRegion(this.value,this.value, $(\'showSingleInput\').checked);', 'style' => 'margin: 10px;', 'div' => false, 'label' => false, 'error' => 'false', 'hiddenField' => false, 'id' => 'regionInput')); 
    }?>

The problems is at second input form 'region'.

I need to pass as first value to JQuery method currently selected value from 'country' form input.

And all the hard stuff I need to do is here:

'getHotelsInRegion(this.value,this.value, $(\'showSingleInput\').checked);'
4

1 回答 1

1

就像是

$('#ModelNameFieldName').change(function() {
    alert($(this).val());
});

应该是诀窍。

于 2013-07-30T13:01:49.997 回答