I am having trouble related to the attached coding.
I am trying to make the object "flight1pic " change depending on what is selected in the drop down menus "airline1" and "aircraft1" .
My problem is when changing "airline1" it all works fine, but when changing "aircraft1" i get the error:
Line: 1
Char: 1
Error: Object Expected
Code: 0 -
function flightpicFunction(){
-
if(document.getElementById('airline1').value == "Qantaslink" && document.getElementById('aircraft1').value == "Boeing 717"){ document.getElementById('flight1pic').innerHTML = "<img src=../images/aircraft/QF_B717.jpg>"; }
-
if(document.getElementById('airline1').value == "Skywest" && document.getElementById('aircraft1').value == "Fokker 100"){ document.getElementById('flight1pic').innerHTML = "<img src=../images/aircraft/XR_F100.jpg>"; }
-
}
-
Can anyone tell me what i might be doing wrong? -
<select size="1" onChange="flightpicFunction();" name="aircraft1" tabindex="3">
-
<option value="BAe 146">BAe 146</option>
-
<option value="Boeing 717">Boeing 717</option>
-
<option value="Boeing 737">Boeing 737</option>
-
<option value="Dash 8">Dash 8</option>
-
<option value="Embraer 120">Embraer 120</option>
-
<option value="Embraer 145">Embraer 145</option>
-
<option value="Embraer 170">Embraer 170</option>
-
<option value="Embraer 190">Embraer 190</option>
-
<option value="Fokker 100">Fokker 100</option>
-
<option value="Fokker 50">Fokker 50</option>
-
<option value="Other">Other</option>
-
</select>
-
9 10150 Frinavale 9,735
Recognized Expert Moderator Expert
I've moved your question from the Java forum into the JavaScript forum where you will find more help with your JavaScript question.
Select HTML elements consist of a bunch of options.
It doesn't make sense to set a select HTML element's "value" property because it doesn't have a value....it has a bunch of options.
-Frinny
@Frinavale
Sorry, can you explain it to me in lamens (easy) terms? I'm good with PHP but I really haven't the slightest clue with Javascript.
I have tried replacing the code: -
document.getElementById('aircraft1').value
-
with this code: -
document.navform.aircraft1.options[document.navform.aircraft1.selectedIndex].value
-
And I still get the same error. :(
Sorry to mess you around. The problem turned out to be my PHP coding.
The PHP coding I had set up changed which javascript function the dropdown menu called up, to one that didn't exist.
All works fine now. Thanks.
You are on the right track with selectedIndex.
try something like: -
var dropdown = document.forms[0].aircraft1;
-
var selection = dropdown[dropdown.selectedIndex].value;
-
Here's a reference for more information: http://www.w3schools.com/jsref/prop_...ectedindex.asp
And by the way, I highly recommend doing your JavaScript debugging in a different browser. Those Internet Explorer error messages just aren't that helpful. There is a handy plugin for Firefox called Firebug; and there are developer tools built in to the Chrome browser.
Happy coding!
I see you got it sorted out before I hit the "post reply" button! Glad to hear it.
Yeah thanx anyway "thesmithma n" and also "Frinavale" . I suppose the best diagnosis is a good night sleep. Was trying to figure it all out at 2am in the morning (before I relised what time it was.)
Frinavale 9,735
Recognized Expert Moderator Expert
Internet Explorer 8 comes with a debugger (hit F12).
If you like FireFox then download a plugin called FireBug.
-Frinny
Dormilich 8,658
Recognized Expert Moderator Expert
two things from my side.
your <select> does not have an ID, so trying to access it with getElementById( ) will only work in IE (given the name is unique, too).
second, a <select> indeed has a value property, which you can read and write.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Erik-Jan Bakker |
last post by:
Hello,
I am stuck with a weird javascript problem.... ;-(
Maybe it's somehting very simple, but I am really stuck in it, right
now.
What's the matter....
When place my website at a different hosting provider my webpage menu
generates the javascript error:
|
by: Andrew Phillipo |
last post by:
I have some code that works everywhere but IE5.0, including IE5.5.
Here is a snippet of where the code seems to go wrong:
Location.prototype.change = function(current) {
this.current = current; // refers to the currently selected estate
agent
var elem = dhtml_get_element(this.id()); // cross browser
getElementById
var oldElem = elem.parentNode; // we can't replace tables using
innerHTML - get the parent element (a div)
|
by: Itzik |
last post by:
Hi
i have any error in my function can i get only error line
Thanks
|
by: westplastic |
last post by:
This one is driving me insane. The script works perfect on Firefox,
but Internet Explorer keeps complaining about "Error Object Expected"
and stuff like that. I've run it through Firefox's Java Console, and
it comes back with no errors. Any pointers on this, would be much
appreciated.
<script type="text/javascript">
<!--
var p = new Array(0,0,0,0,0)
var c = new Array(0,0,0,0,0,0,0,0,0)
|
by: Jinx08 |
last post by:
I am probably an itermediate user when it comes to flash however I am at a loss with this problem. I have posted numerous flash files to the internet and never had this problem however the key there is those were all using older versions of Flash and using windows xp. I now own Flash CS3 and I am running Windows Vista I am not sure if this has anything to do with it. Anyway I used dreamweaver to create and upload the page and file.When I go to...
| |
by: cfps.Christian |
last post by:
I've written a .js file and put the script in my usercontrol:
<script src="myscript.js" />
Added the attributes to my controls:
lbl.Attributes.Add("onclick", "DoWork(this);")
- Also tried "javascript:DoWork(this);"
- and "javascript:DoWork();" - to see if it was the "this"
I've also tried the RegisterClientScriptInclue() method to register
this script as well to no avail.
|
by: tridirk |
last post by:
Hi; I am getting a Objceted Expected Error on my forum site. I can't find what is wrong?
Line:
Char:
Error: Object expected
Code:0
the site is My SMF Forum
|
by: Joe Gutierrez |
last post by:
Please help, I'm getting this error, Object expected, Code: 0 in Internet Explorer (not in Firefox, though). Here is the link:
http://www.uatparts.com/miva/merchant.mvc?Screen=PROD&Store_Code=uatparts&Product_Code=UAT-9931&Category_Code=
I'm worried that my customers might shy away and not buy from me when they see this error. What do I need to do in order to stop this error from appearing? Here is the entire code:
<!DOCTYPE HTML...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |