By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,776 Members | 1,233 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,776 IT Pros & Developers. It's quick & easy.

Firefox problem with .value

P: n/a
Does anyone know how I can fix the code below to work in Firefox,it
works perfectly well in IE, the problem is that I have to use Firefox
for this assignment.

Thankyou

Michael

<html>
<body>

<p>Please enter the type of book that you wish to purchase:</p>
<select name="hardback"
onchange="if(this.selectedIndex)cover=+(this[this.selectedIndex].value);">
<option value= "0" SELECTED> Select Type of Book--(Default
Paperback)</option>
<option value="4.00">Standard Hardback</option>
<option value="6.00">Limited Edition HardBack</option>
</td>
<td>
<form>
<INPUT TYPE="BUTTON" VALUE='reset'onClick='hardback.value=0'>
</form>
</body>
</html>
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
mi*****@hotmail.com (MickG) writes:
Does anyone know how I can fix the code below to work in Firefox,it
works perfectly well in IE, the problem is that I have to use Firefox
for this assignment.
You forgot to tell us what it should do.
<p>Please enter the type of book that you wish to purchase:</p>
<select name="hardback"
onchange="if(this.selectedIndex)cover=+(this[this.selectedIndex].value);">
This select element is not inside any form. That makes it hard to refer to
it. You can't go through the document.forms collection, and it doesn't
have an id.
<form>
The form needs an action to be valid.
<INPUT TYPE="BUTTON" VALUE='reset'onClick='hardback.value=0'>
There is a space missing between the VALUE and onClick attributes.
You are referring to "hardback" here. There is no global variable
declared of that name. IE might create global variables referring
to named elements, but as you can see, other browsers don't. So,
you need some way of referring to the select with name="hardback".
</form>


My suggestion: put the select in the same form as the button. Then
refer to it as:
onclick="this.form.elements['hardback'].value = 0;"
(or just make the button an <input type="reset">).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #2

P: n/a
thanks for the help, it works perfectly now.

Michael

Jul 23 '05 #3

P: n/a
Lee
MickG said:

Does anyone know how I can fix the code below to work in Firefox,it
works perfectly well in IE, the problem is that I have to use Firefox
for this assignment.

Thankyou

Michael

<html>
<body>

<p>Please enter the type of book that you wish to purchase:</p>
<select name="hardback"
onchange="if(this.selectedIndex)cover=+(this[this.selectedIndex].value);">


IE often makes guesses if your code is missing something.
Sometimes the guess is correct, and it "works perfectly well":

if(this.selectedIndex)cover=+(this.options[this.selectedIndex].value)

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.