Total members 11894 |It is currently Mon Nov 25, 2024 12:19 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka



Go to page 1, 2  Next


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....




Author:
Beginner
User avatar Posts: 54
Have thanks: 0 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>



_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

thanku dude....
but how to put that message(male is option chose) below that select option element?


Author:
Beginner
User avatar Posts: 54
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!!!


Author:
Beginner
User avatar Posts: 54
Have thanks: 0 time

do u you want to show the error in a bar or something like that ?

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 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..


Author:
Beginner
User avatar Posts: 54
Have thanks: 0 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

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 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?


Author:
Beginner
User avatar Posts: 54
Have thanks: 0 time

yes ,you can write anything as string .

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

For this message the author DrRakha has received gratitude : saics

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>


Author:
Beginner
User avatar Posts: 54
Have thanks: 0 time
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

  Related Posts  to : how to load the form elements depending on selection option
 Good looking selection box with image per option     -  
 load class to applet- load frame class to applet     -  
 php login form (sign-in form)     -  
 selection sort     -  
 C++ Selection Sort     -  
 Help with selection sort for strings?     -  
 validate age entered as selection box in javascript     -  
 selection of checkbox in buttongroup in netbeans     -  
 fill selection options from list     -  
 calculate data from multiple selection     -  



cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com