homepage Welcome to WebmasterWorld Guest from 54.197.215.146
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Form value from multiple selections
lozmatic




msg:3374618
 1:14 pm on Jun 21, 2007 (gmt 0)

Hi,

I'm looking for an example of a form that has this particular type of function.

A 'information' box that is populated from 2 drop down menus. The first one to select a 'topic' and the second one to select a 'country'.

So the user would select 'sports' and 'uk' form the 2 menus and press a button to populate the 'information' box.

And repeat the process any number of times.

I need to see something along these lines working on a site so I can prove to someone that it can be done. But haven't had luck finding anything like it.

Thanks,

Lawrence

 

Trace




msg:3374646
 1:41 pm on Jun 21, 2007 (gmt 0)

Easy enough;
<script type="text/javascript">
function doIt(){
var temp01 = document.getElementById('lstTest1')[document.getElementById('lstTest1').selectedIndex].value;
var temp02 = document.getElementById('lstTest2')[document.getElementById('lstTest2').selectedIndex].value;

document.getElementById('txtArea').value = temp01 + ' ' + temp02
}
</script>

<form>
<p>
<select name="lstTest1" id="lstTest1">
<option value="something">something</option>
<option value="other">other</option>
</select>
</p>

<p>
<select name="lstTest2" id="lstTest2">
<option value="red">red</option>
<option value="green">green</option>
<option value="blue">blue</option>
</select>
</p>

<p><input type="button" value="populate" onclick="doIt();"></p>

<p><textarea name="txtArea" id="txtArea" rows="5" cols="20"></textarea></p>
</form>


lozmatic




msg:3374673
 2:05 pm on Jun 21, 2007 (gmt 0)

Damn, I wish I could do that just as easily.

Thanks.

Loz

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved