I'm using below javascript to set value to cell in a tabular form.
<script type="text/javascript">
function eventListener(pThis)
{
$('input[name="f04"]').change(function(){
var that = this;
var vRow = "f10_"+pThis.id.substr(pThis.id.indexOf('_')+1);
$.post("wwv_flow.show",
{p_request : "APPLICATION_PROCESS=GET_AMOUNT",
p_flow_id : $v("pFlowId"),
p_flow_step_id : $v("pFlowStepId"),
p_instance : $v("pInstance"),
x01 : $(this).val()
},
function(data){
$('input[id="f10_0002"]').val(data);
},
"text"
);
});
}
</script>
I need to use value in var vRow instead of f10_0002 in $('input[id="f10_0002"]').val(data);.
I have tried with $('input[id=vRow]').val(data); and $('input[id='"'+vRow+'"']').val(data);
But doesn't work. javascript is not worked in these situations. but $('input[id="f10_0002"]').val(data); is worked.
how could i use value in var vRow for this ?
While using the selector
input[id=value]is technically right (because of the jQuery attribute selector), it isn't necessary. The main reason is because you're targeting an element by ID. Javascript has a special method that is especially fast, which I'm sure jQuery uses internally (document.getElementById) when you specify you're selecting by ID. To trigger the selection of an element by ID, you can use the#character at the beginning of the selector string. Since you are trying to use the value of a variable as well, you can concatenate"#"andvRow, like:#is the equivalent of matching an element by ID. If you look at the jQuery selectors page ( http://api.jquery.com/category/selectors ), you'll see there are several special characters to help with selecting elements. As I said,#is for ID....is for class, etc. So instead of having jQuery parse the string "input[id=value]" and do a lot of extra processing, you can help jQuery do it more efficiently by simply using#.