Skip to main content
October 24, 2010
Question

Form with onchange function

  • October 24, 2010
  • 1 reply
  • 605 views

I want to give option like pay by credit card or check.

If one select credit card in select option it opens credit card related form inputs/Check than check related form inputs before submiting form.

I would start like

<cfform action"" method=""Post>

<cfselect name="paymenttype" query="test" display="paymenttype" value="paymenttype">

<option value ="other">Other</>

</select>

<cfif form.paymenttype = "Credit Card">

<cfinput type="Test" name="creditcomp">

<cfelseif form.paymenttype = "check">

<cfinput type="text" name="bankinfo">

</cfif>

<input type="submit" value="Submit"></cfform>

I belive I need to use Java script onChange event but I never did Java script before, can any one help me on it?

I have been using cfcase and submiting form at each and than made session variable to generate appropriate result but now I wanrt to do some change.

    This topic has been closed for replies.

    1 reply

    Inspiring
    October 24, 2010

    For learning js, I recommend the book, Teach Yourself Javascript in 24 Hours.  It's how I learned.  There are also tutorials on webmonkey.

    For what you are trying to do specifcally, I would put the credit card and bank stuff in separate divs and use js to show and hide them.  Google "javascript show hide"  to find code samples.