Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 30th, 2004, 10:17 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default <P> Annoyance

Ok guys,

Here it is:

I have a list box and a go button that populates 3 <P> tags using innerText. However I only want this to happen on one selection. If the user selects anything else I want the <P> tags to be emptied and revert back to their original state. I've tried the following:

<P ID="P1"></P>
<P ID="P2"></P>
<P ID="P3"></P>
<form name ="form1">
<select name = "Selected">
<option>0</option>
<option>1</option>
<option>2</option>
</select>
<input type ="button" name ="but1" value ="Go" onclick ="populate()">
</form>
<script language =javascript>
function populate(){
if(Selected.selectedIndex = 0){
P1.innerText="Some Text"
P2.innerText="Some Text"
P3.innerText="Some Text"}}
if(Selected.selectedIndex = 1){
P1.innerText=''
P2.innerText=''
P3.innerText=''}
if(Selected.selectedIndex = 2){
P1.innerText=''
P2.innerText=''
P3.innerText=''}
}
</script>

Help!
cheers
interrupt

__________________
\'sync\' &lt;cr&gt;
The name specified is not recognized as an internal or external command, operable program or batch file.
 
Old August 9th, 2004, 04:26 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

The lines like this:

if(Selected.selectedIndex = x){

should be:

if(Selected.selectedIndex == x){

HTH,

Snib

<><




Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch 8: <asp:image> inside <a> & ext.CSS (pg. 274) epc BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 July 12th, 2008 04:37 AM
create <ul> with alternating class on <li> element Brian Campbell XSLT 2 November 3rd, 2006 06:07 PM
<style> tags in a <body> vs. <div> bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 27th, 2005 08:50 AM
<marquee><b>About CHAT App. in PHP4</b></marquee> Ramkrishna PHP How-To 1 September 11th, 2004 07:01 AM
<STRONG> vs <B> and <EM> vs <I> anshul HTML Code Clinic 12 September 1st, 2004 05:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.