Skip to main content
Inspiring
October 8, 2013
Question

onChange vs. onclick

  • October 8, 2013
  • 2 replies
  • 1038 views

this code is worked fine with onchange event.  Instead of onchange, i want to have the link below(<a id="myLink" href="##" onclick="whatsUp();">link text</a>) and work the same as onchange, meaning when i
click on the link text , i need to get the url.t_item?

<script type="text/javascript">
function whatsUp() {
document.medform.t_item.value)
}
function show() {
alert(document.medform.t_item.value)
}
</script>

<cfif isDefined("form.t_item")>

<cfdump var="#form#"><br />

</cfif>
   
<cfform name="medform" action="#cgi.SCRIPT_NAME#">
Item name: <cfinput autosuggest="cfc:cfc.gg.lookupArt({cfautosuggestvalue})" type="text" name="t_item" size="50" typeahead="yes"  onChange="whatsUp()">

<a id="myLink" href="##" onclick="whatsUp();">link text</a>

</cfform>

    This topic has been closed for replies.

    2 replies

    Legend
    December 2, 2013

    Your whatsUp() function appears to have a typo: I see a closing paren but no opeing one and I don't see what it doing anything even if you correct the stray paren. Maybe you meant to call alert()?

    Legend
    October 8, 2013

    Looks pretty much ok, so what happens when you click on the link? There is a missing alert in your whatsUp() function but I think you know that.