0

I have a column in grid which is of hyperlink type and when I click, it should take me URL on basis of JavaScript function. Now my question is how should I pass database column name as parameter into JavaScript function. I tried something which is not fruitful.

<ItemTemplate>

     <td colname="time_type" >
   <a ><%#DataBinder.Eval(Container.DataItem, "TYPE_SEQ")%></a> 

         </td>


</ItemTemplate>

function Time_type(<%# Eval( "TIME_TYPE_INDICATOR" ) %>,<%# Eval( "TYPE_SEQ" ) %>){
  var url;       
if (<%# Eval( "INDICATOR" ) %> == 'O'){
url= www.something.com/<%# Eval( "TYPE_SEQ" ) %>?;

}
else if(<%# Eval( "INDICATOR" ) %> == 'T'){
url= www.something.com/<%# Eval( "TYPE_SEQ" ) %>?;

}
}

The function here is taking 2 database columns as parameters and based on one parameter other parameter is used as query string in URL. My javascript function is not working and I know it is not right way to pass paramaters like this.Please help. **Also please show me how to call this function on hyperlink click **

user3154990
  • 555
  • 4
  • 13
  • 27

1 Answers1

0

I might sound stupid but why use so difficult names for function(someName,someOtherName)... For example doesn't functions work like this:

function someFunction(val1,val2){
    var troll = val1+val2;
    return troll;
}
var temp = someFunction(1,2); // temp is now 3. So here is the right way to call functions and pass it parameters.

I'm still quite new to coding in general but I think from hyperlink it goes like this:

<a onClick='someFunction(someValue,someOtherValue);'></a>

Also I would put in quotes when assigning variable: url = "www.something.com/"+someVariable;

user3647971
  • 1,069
  • 1
  • 6
  • 13