Jump to content

onClick Event?


JLongo3925

Recommended Posts

I am new to programming and do not know what I can and can not do with certain languages.

 

How can I create decisions on the fly? Would I use Javascript? For instance, if a radio button is selected and the value equals "sometext", then display a text field. Otherwise, do not display a text field.

 

Using pseudo-code, would this work or something similar to this?

 

 

function sampleFunction()

{

if ($someVariable ==true)

{

document.write[];

}

}

Link to comment
Share on other sites

You do not create decisions on the fly. You pre-create the possible conditions that the user may choose.

 

What you want to do there is quite advanced and I think you should have few basic tutorials in Javascript first.

 

But to elaborate and expand on your idea, writing or other HTML elements using Javascript is not really recommended. What you should do is have a script that can hide/show

or

block elements. Then place the inputs in the block elements and set their style to display:none. Then you can start using the events (onClick, onFocus, onBlur etc) to fire/initiate functions:

 






 

Above is not tested, however it's just a basic idea of how you would write your code. However if you use "JQuery" javascript library, it will make your life 100% easier :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...