LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   dynamically add objects in JavaScript (https://www.linuxquestions.org/questions/programming-9/dynamically-add-objects-in-javascript-293128/)

djgerbavore 02-21-2005 04:05 PM

dynamically add objects in JavaScript
 
hello,

i have a form and when a user hits a certain radio button. I want a certain piece of html code to run. For example:

Code:

<input type='radio' value=0 name='myradio'>1
<input type='radio value =0 name='myradio'>2

now i want to add javascript to add a certain drop down menu depending on what radio button they selected, this is what i have so far:

Code:

<input type='radio' value=0 name='myradio' onclick = document.myform.myradio.value = 1>1
<input type='radio' value=0 name='myradio' onclick = document.myform.myradio.value=2>2

<script>
if(docuemnt.myform.myradio.value == 1) {
        write code
}
else {
        some other code
}

when i load this page, i get an errory saying that document.myform.myradio.value is either null or not an object.

My question is how can dynamically create html code, when a user select a radio button. Remind you that each radio button will produce different html code.

thanks,

djgerbavor3

jonaskoelker 03-11-2005 09:41 PM

have a look at span or div tags and their innerHTML-attributes. It may (or may not) help.


All times are GMT -5. The time now is 07:59 AM.