Skip to main content
Inspiring
Oct 8, 2013 3:17 PM UTC
Question

onChange vs. onclick

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 is closed to new replies. Start a new post to keep the conversation going.

    2 replies

    Legend
    Dec 2, 2013 5:00 PM UTC

    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()?

    Translate
    Legend
    Oct 8, 2013 7:48 PM UTC

    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.

    Translate