473,325 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

No properties

I was wondering if anyone could help. I have a drop down box which when
an option is selected changes the picture that is shown. I would also
like it to show a message explaining what is shown in the picture, its
this bit that I can't get to work. The way it should work is that each
different message is in its own form which should appear when the
option is selected.

Anyway, the javascript I have for this is:

function changeColour() {
var selection = (document.select.colour.selectedIndex);
var picture = ((document.select.colour.options[selection].value) +
".jpg");
var text = ((document.select.colour.options[selection].value) +
"Text");
document.colour.src = picture;
document.text.style.display = "";
}

Its saying that document.text has no properties, so I know what its
saying but not why and I've run out of ideas right now, can anyone
help?

It would be much appreciated!

Thank you

May 31 '06 #1
5 1190
Flic wrote on 31 mei 2006 in comp.lang.javascript:
I was wondering if anyone could help. I have a drop down box which when
an option is selected changes the picture that is shown. I would also
like it to show a message explaining what is shown in the picture, its
this bit that I can't get to work. The way it should work is that each
different message is in its own form which should appear when the
option is selected.

Anyway, the javascript I have for this is:

function changeColour() {
var selection = (document.select.colour.selectedIndex);
var picture = ((document.select.colour.options[selection].value) +
".jpg");
var text = ((document.select.colour.options[selection].value) +
"Text");
document.colour.src = picture;
document.text.style.display = "";
}

Its saying that document.text has no properties, so I know what its
saying but not why and I've run out of ideas right now, can anyone
help?

It would be much appreciated!


Show us a total example in the sense of "html + code", or an url.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 31 '06 #2
<html>
<head><title>Colour combinations</title>

<script type="text/javascript">

function changeColour() {
var selection = (document.select.colour.selectedIndex);
var picture = ((document.select.colour.options[selection].value) +
".jpg");
var text = ((document.select.colour.options[selection].value) +
"Text");
document.colour.src = picture;
document.text.style.display = "";
}
function resize() {
window.resizeTo(600, 675)
}

</script>

</head><body>

<table width=250 border=0 >
<tr align=center><td>
<form name="select">
<select name="colour" onchange="changeColour()">
<option value="diamondJet">Black / Grey</option>
<option value="aquaCapri">Blue / Light Blue</option>
<option value="lightAmethyst">Purple / Light Purple</option>
<option value="fireSiam">Red / Orange</option>
<option value="roseGarnet">Dark Red / Pink</option>
</select>
</td></tr></form>

<tr><td><img name="colour" src="diamondJet.jpg" alt="Photo"></td></tr>

<tr><td align=center>
<form name="diamondJetText" style="display:none"><b>Black:</b>
Jet<br><b>Grey:</b> Black Diamond</form>
<form name="aquaCapriText" style="display:none"><b>Dark Blue:</b> Capri
Blue<br><b>Light Blue:</b> Aquamarine</form>
<form name="lightAmethystText" style="display:none">purple</form>
<form name="fireSiamText" style="display:none">fire</form>
<form name="roseGarnetText" style="display:none">pink</form>
<td></tr>

<tr align=center><td>Don't see the colours you want?<br>
Click for a <a href="crystals.html" onClick="resize()">full colour
chart</a></td></tr>

</body>

</html>

May 31 '06 #3
Flic wrote on 01 jun 2006 in comp.lang.javascript:
<html>
<head><title>Colour combinations</title>
Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at the
top of the article, then click on the "Reply" at the bottom of the
article headers. <http://www.safalra.com/special/googlegroupsreply/>

<script type="text/javascript">

function changeColour() {
var selection = (document.select.colour.selectedIndex);
This works only on IE, use id and getElementById()
var picture = ((document.select.colour.options[selection].value) +
".jpg");
Do not unse unnecessary ()s
var text = ((document.select.colour.options[selection].value) +
"Text");
document.colour.src = picture;
same
document.text.style.display = "";
}

[unused function ]
</script>

</head><body>

<table width=250 border=0 >
this table s not terminated with </table> so the HTML will not "work"
why mix css and ancient attributes?


<tr align=center><td>
<form name="select">
<select name="colour" onchange="changeColour()">
<option value="diamondJet">Black / Grey</option>
<option value="aquaCapri">Blue / Light Blue</option>
<option value="lightAmethyst">Purple / Light Purple</option>
<option value="fireSiam">Red / Orange</option>
<option value="roseGarnet">Dark Red / Pink</option>
</select>
</td></tr></form>
This form will never execute, so why a form?

your changeColour() will fire, but will not be effective, because:


<tr><td><img name="colour" src="diamondJet.jpg" alt="Photo"></td></tr>

<tr><td align=center>
<form name="diamondJetText" style="display:none"><b>Black:</b>
Jet<br><b>Grey:</b> Black Diamond</form>
probably you would mean to use <div> in stead of <form>?
<form name="aquaCapriText" style="display:none"><b>Dark Blue:</b> Capri
Blue<br><b>Light Blue:</b> Aquamarine</form>
same
<form name="lightAmethystText" style="display:none">purple</form>
same
<form name="fireSiamText" style="display:none">fire</form>
same
<form name="roseGarnetText" style="display:none">pink</form>
same
<td></tr>
[ unimportand part]
</body>

</html>


try this:
=================================
<html>
<head>

<script type="text/javascript">

function changeColour() {

var selColour = document.getElementById('selColour')
var selection = selColour.selectedIndex;
var text = selColour.options[selection].value + "Text";
alert(text)

document.getElementById('diamondJetText').style.di splay = "none";
document.getElementById('aquaCapriText').style.dis play = "none";
document.getElementById('lightAmethystText').style .display = "none";
document.getElementById('fireSiamText').style.disp lay = "none";
document.getElementById('roseGarnetText').style.di splay = "none";
document.getElementById(text).style.display = "";

var picture = selColour.options[selection].value + ".jpg";
document.getElementById('picColour').src = picture;
alert(picture)

}

</script>

</head><body>

<select id="selColour" onchange="changeColour()">
<option >--- choose ---</option>
<option value="diamondJet">Black / Grey</option>
<option value="aquaCapri">Blue / Light Blue</option>
<option value="lightAmethyst">Purple / Light Purple</option>
<option value="fireSiam">Red / Orange</option>
<option value="roseGarnet">Dark Red / Pink</option>
</select>
<br><br>
<img id="picColour" src="diamondJet.jpg" alt="Photo">
<br><br>
<div id="diamondJetText" style="display:none"><b>Black:</b>
Jet<br><b>Grey:</b> Black Diamond</div>

<div id="aquaCapriText" style="display:none"><b>Dark Blue:</b> Capri
Blue<br><b>Light Blue:</b> Aquamarine</div>

<div id="lightAmethystText" style="display:none">purple</div>

<div id="fireSiamText" style="display:none">fire</div>

<div id="roseGarnetText" style="display:none">pink</div>

</body>

</html>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 31 '06 #4

Evertjan. wrote:
Flic wrote on 01 jun 2006 in comp.lang.javascript:
<html>
<head><title>Colour combinations</title>


Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at the
top of the article, then click on the "Reply" at the bottom of the
article headers. <http://www.safalra.com/special/googlegroupsreply/>

<script type="text/javascript">

function changeColour() {
var selection = (document.select.colour.selectedIndex);


This works only on IE, use id and getElementById()
var picture = ((document.select.colour.options[selection].value) +
".jpg");


Do not unse unnecessary ()s
var text = ((document.select.colour.options[selection].value) +
"Text");
document.colour.src = picture;


same
document.text.style.display = "";
}

[unused function ]

</script>

</head><body>

<table width=250 border=0 >


this table s not terminated with </table> so the HTML will not "work"
why mix css and ancient attributes?


<tr align=center><td>
<form name="select">
<select name="colour" onchange="changeColour()">
<option value="diamondJet">Black / Grey</option>
<option value="aquaCapri">Blue / Light Blue</option>
<option value="lightAmethyst">Purple / Light Purple</option>
<option value="fireSiam">Red / Orange</option>
<option value="roseGarnet">Dark Red / Pink</option>
</select>
</td></tr></form>


This form will never execute, so why a form?

your changeColour() will fire, but will not be effective, because:


<tr><td><img name="colour" src="diamondJet.jpg" alt="Photo"></td></tr>

<tr><td align=center>
<form name="diamondJetText" style="display:none"><b>Black:</b>
Jet<br><b>Grey:</b> Black Diamond</form>


probably you would mean to use <div> in stead of <form>?
<form name="aquaCapriText" style="display:none"><b>Dark Blue:</b> Capri
Blue<br><b>Light Blue:</b> Aquamarine</form>


same
<form name="lightAmethystText" style="display:none">purple</form>


same
<form name="fireSiamText" style="display:none">fire</form>


same
<form name="roseGarnetText" style="display:none">pink</form>


same
<td></tr>

[ unimportand part]

</body>

</html>


try this:
=================================
<html>
<head>

<script type="text/javascript">

function changeColour() {

var selColour = document.getElementById('selColour')
var selection = selColour.selectedIndex;
var text = selColour.options[selection].value + "Text";
alert(text)

document.getElementById('diamondJetText').style.di splay = "none";
document.getElementById('aquaCapriText').style.dis play = "none";
document.getElementById('lightAmethystText').style .display = "none";
document.getElementById('fireSiamText').style.disp lay = "none";
document.getElementById('roseGarnetText').style.di splay = "none";
document.getElementById(text).style.display = "";

var picture = selColour.options[selection].value + ".jpg";
document.getElementById('picColour').src = picture;
alert(picture)

}

</script>

</head><body>

<select id="selColour" onchange="changeColour()">
<option >--- choose ---</option>
<option value="diamondJet">Black / Grey</option>
<option value="aquaCapri">Blue / Light Blue</option>
<option value="lightAmethyst">Purple / Light Purple</option>
<option value="fireSiam">Red / Orange</option>
<option value="roseGarnet">Dark Red / Pink</option>
</select>
<br><br>
<img id="picColour" src="diamondJet.jpg" alt="Photo">
<br><br>
<div id="diamondJetText" style="display:none"><b>Black:</b>
Jet<br><b>Grey:</b> Black Diamond</div>

<div id="aquaCapriText" style="display:none"><b>Dark Blue:</b> Capri
Blue<br><b>Light Blue:</b> Aquamarine</div>

<div id="lightAmethystText" style="display:none">purple</div>

<div id="fireSiamText" style="display:none">fire</div>

<div id="roseGarnetText" style="display:none">pink</div>

</body>

</html>


Thank you very much for that! I'm only recently new to javascript so
still picking up things as I go along. I hadn't thought of using div's
for the second lot, I had tried using anchors but found that those
worked in ie but not firefox, I'll have to investigate div's more. I
also didn't know that you could use options without the form, but that
does make sense. Thats why I'm doing this site so that I can learn new
things, thank you very much for your help!

May 31 '06 #5
Flic said:
Thank you very much for that! I'm only recently new to javascript so
still picking up things as I go along. I hadn't thought of using div's
for the second lot, I had tried using anchors but found that those
worked in ie but not firefox, I'll have to investigate div's more. I
also didn't know that you could use options without the form, but that
does make sense. Thats why I'm doing this site so that I can learn new
things, thank you very much for your help!


You only need the form if you're planning to submit it to a server - for
scripting on the page using javascript, you don't need it.

--
http://www.niftybits.ukfsn.org/

remove 'n-u-l-l' to email me. html mail or attachments will go in the spam
bin unless notified with [html] or [attachment] in the subject line.

Jun 1 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rick Austin | last post by:
I recently had to perform a reinstalltion of Windows XP (my registry seems to have become corrupt). After this completed I had to reinstall all applications since most use the registry for settings,...
4
by: Lyn | last post by:
Hi, This question may seem a bit academic... To learn more about Access VBA, I have been enumerating the properties of various form controls. This was mostly successful and I have learned a lot...
10
by: Sunny | last post by:
Hi, I have an old problem which I couldn't solve so far. Now I have found a post in that group that gave me an idea, but I can not fully understand it. The problem is: I'm trying to use a...
6
by: JerryP | last post by:
Hello, is there a way to launch the property dialogue for a directory from my c# app ? I would also like to launch the User Account Properties from Active Directory Users and Computers, and the...
3
by: Martin Montgomery | last post by:
I have, for example, a property called myProperty. I would like, when using a property grid to display the property name as "My Property". Is this possible. Is there an attribute etc Thank ...
7
by: Donald Grove | last post by:
Is it possible to retrieve field properties from a table in access2000 using code? I have tried: " dim dbs as dao.database dim tbl as dao.tabledef dim fld as dao.field dim prop as...
1
by: Christophe Peillet | last post by:
I have a CompositeControl with two types of properties: 1.) Mapped Properties that map directly to a child control's properties (ex.: this.TextboxText = m_txt.Text). These properties are handled...
7
by: Anderskj | last post by:
Hi! I am developing a c# application. I have a interface (which can change therefore my problem) If i do like this: List<PropertyInfoproperties = new List<PropertyInfo>();...
0
by: =?Utf-8?B?UmljayBHbG9z?= | last post by:
For some unknown reason (user error?), I cannot get a NameValueCollection to persist in the app.config file. Unlike other settings, I cannot get the String Collection Editor GUI to allow my to...
4
by: FullBandwidth | last post by:
I have been perusing various blogs and MSDN pages discussing the use of event properties and the EventHandlerList class. I don't believe there's anything special about the EventHandlerList class in...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.