Total members 10262 | Gratitudes |It is currently Thu May 24, 2012 9:45 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 17 posts ]  Go to page 1, 2  Next
Author Question
 Question subject: how to load the form elements depending on selection option
PostPosted: Thu Jan 13, 2011 4:56 pm 
Offline
Beginner
User avatar

Joined: Sun Jan 09, 2011 2:16 pm
Posts: 56
Has thanked: 1 time
Have thanks: 0 time

hi friendz...
Any body help on this...i want to create a page with some form elements(text,password,radio buttons,check boxes...etc)..
and the problem is... the very first element in the form is a select option(its my requirement)...following some elements
if i change the select option in the dropdown then the remaining all form elements or some of them should change....i.e it will display the different form elements depending on the select option
any one help me on this with the code.....

thanku in advance....

_________________
technoyouth


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: how to load the form elements depending on selection option
PostPosted: Fri Jan 14, 2011 1:10 am 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
something like this .

Code:

<form name="form">
<
select name="someselect"  onchange="javascript:doSomething();">
<
option value="male">male</option>
<
option value="female">female</option>
</
select>
</
form>

<
script>

 function doSomething(){

if (form.someselect.options[form.someselect.selectedIndex].value=='male')
{
 alert("male is option chose ");
}
}
</script>


_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: how to load the form elements depending on selection option
PostPosted: Fri Jan 14, 2011 11:38 am 
Offline
Beginner
User avatar

Joined: Sun Jan 09, 2011 2:16 pm
Posts: 56
Has thanked: 1 time
Have thanks: 0 time
thanku dude....
but how to put that message(male is option chose) below that select option element?

_________________
technoyouth


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: how to load the form elements depending on selection option
PostPosted: Sun Jan 16, 2011 3:13 pm 
Offline
Beginner
User avatar

Joined: Sun Jan 09, 2011 2:16 pm
Posts: 56
Has thanked: 1 time
Have thanks: 0 time
any one please will help on this??
how to add the elements to that page only when the java script on "select" option run...that is insted of displaying that massage in alert(in the above example) a message should be displayed there itself the page contain select scroll....
thank u in advance!!!

_________________
technoyouth


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: how to load the form elements depending on selection option
PostPosted: Sun Jan 16, 2011 9:03 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
do u you want to show the error in a bar or something like that ?

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: how to load the form elements depending on selection option
PostPosted: Mon Jan 17, 2011 12:39 pm 
Offline
Beginner
User avatar

Joined: Sun Jan 09, 2011 2:16 pm
Posts: 56
Has thanked: 1 time
Have thanks: 0 time
no not like that...
you are displaing that "male is option chose " in the alert window....but my desire is ti print that maeesge below the select ..that means the message should be displayed in that page only..

_________________
technoyouth


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: how to load the form elements depending on selection option
PostPosted: Mon Jan 17, 2011 10:24 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
you can add under the select
Code:
<div id="mydiv">
 </
div>
 


and in JavaScript use
Code:

document
.getElementById('mydiv').innerHTML ' your message ';
 


it will change dynamically

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: how to load the form elements depending on selection option
PostPosted: Tue Jan 18, 2011 5:51 pm 
Offline
Beginner
User avatar

Joined: Sun Jan 09, 2011 2:16 pm
Posts: 56
Has thanked: 1 time
Have thanks: 0 time
thanku very much bro...
last one question bro please ....can we also write any number of lines of html code at "your message" place in JavaScript?

_________________
technoyouth


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: how to load the form elements depending on selection option
PostPosted: Tue Jan 18, 2011 9:53 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
yes ,you can write anything as string .

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )



For this message the author msi_333 has received gratitude : saics
TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: how to load the form elements depending on selection option
PostPosted: Sun Jan 23, 2011 2:53 pm 
Offline
Beginner
User avatar

Joined: Sun Jan 09, 2011 2:16 pm
Posts: 56
Has thanked: 1 time
Have thanks: 0 time
hi msi_333 bro...
one more doubt regarding this code...can't we insert the data in the table using <div>..tag
Bro..jst watch the following code and give me a suggestion to place it in the table...


<script>
function doSomething(){

if (form.someselect.options[form.someselect.selectedIndex].value=='male')
{
alert("male is option chose ");
document.getElementById('mydiv').innerHTML = '<td>Name:</td><td><input type=text

name="s"></td><br> ';
}
}
</script>

<body>
<form name="form">
<table>
<tr>
<td>select</td>
<td><select name="someselect" onchange="javascript:doSomething();">
<option value="male">Male</option>
<option value="female">female</option>
</select></td>
</tr>
<tr>
<td>hai</td>
<td>hai</td>
</tr>
<tr>
<div id="mydiv">
</div>
</tr>
</form>
</body>

_________________
technoyouth


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 17 posts ]  Go to page 1, 2  Next
Quick reply


  

 Similar topics
 help me How do I load image from my pc to matlab
 Add border around ordered list elements
 getting gst, pst total to diplay in my javascript form
 lesson6: XSD Complex Empty Elements
 How to make PHP form data saved into txt file
 php User Registration Form
 complete registration form with validation
 php login form (sign-in form)
 validate age entered as selection box in javascript
 fill selection options from list

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team