Web Analytics Made Easy -
StatCounter newbie needs help with function and variable - CodingForum


No announcement yet.

newbie needs help with function and variable

  • Filter
  • Time
  • Show
Clear All
new posts

  • newbie needs help with function and variable

    i am trying to do something simple but it is not working. i am trying to call a javascript function from a hyperlink and pass the function a string variable. the string variable i am sending to the function has been dynamically generated by asp.net code from a database, but ive looked at the HTML code being outputted at it is like this:

    <a href='javascript:func_Link('SMI1133')'>SMI1133</a>

    my function is then supposed to do 2 things:

    1. redirect the page to a URL depending upon the selected item in myDropDownList.
    2. append the input variable onto the end as a query string:

    script language="javascript">
    function func_Link(code)
    document.form1.action=document.form1.myDropDownList.value + ".aspx?code=" + code;

    can anyone tell me why this is not working? i am getting a syntax error message. if i remove the input variable so that the HTML being outputted it works but then i dont have a variable to append to my query string!:

    <a href='javascript:func_Link()'>SMI1133</a>

    thanks for any help

  • #2
    You have nested single quotes. Use double quotes around the href attribute value.

    <a href="javascript&#58;func_Link('SMI1133')">SMI1133</a>
    vBulletin Mods That Rock!


    • #3
      thanks - that worked!