Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-15-2013, 03:18 PM   PM User | #1
jamhead
New to the CF scene

 
Join Date: Jan 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
jamhead is an unknown quantity at this point
join all form field in text-area - problem with internet explorer

Hi there,

i´m quite new to javascript and have a question to my first "project":

I want a documentation utility for work in which i can document hotline-calls.
So i made a form and an output textarea where all form field should display after pressing the button.

http://jsfiddle.net/yQy7a/

while this works on firefox and chrome it wont work on internet explorer. But I need an internet explorer compatible solution...can you point out whats wrong with it ?

I posted it on jsfiddle.....ffel free to "mess arround" with it :

greetings from germany,
Philipp
jamhead is offline   Reply With Quote
Old 01-15-2013, 07:07 PM   PM User | #2
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 454 Times in 452 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
you are asking for the value of your selects:
Code:
var text4 = document.getElementById("fehlerquelle").value
but the options only have text:
Code:
<select size="1" id="fehlerquelle" name="fehlerquelle">
<option>HVT</option>
<option>KVZ</option>
</select>
if you want to use their values values you should give them values (which can be independent from the option text):

Code:
<select size="1" id="fehlerquelle" name="fehlerquelle">
<option value="234">HVT</option>
<option value="KVZ">KVZ</option>
</select>
FF and Chrome are a lot more lenient - if they are asked for an option value and there isn't one they will use the option text as a fallback, but this is one of the few instances where I think that IE is doing the right thing
xelawho is offline   Reply With Quote
Old 01-15-2013, 07:13 PM   PM User | #3
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 951
Thanks: 7
Thanked 98 Times in 98 Posts
WolfShade is an unknown quantity at this point
Quote:
Originally Posted by xelawho View Post
...but this is one of the few instances where I think that IE is doing the right thing
For me, those instances are rare, indeed. But I agree with you.. options should be forced to have both value and text.
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 01-15-2013, 07:25 PM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,237
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
I'm on the fence on this one.

When an <option> without a value= is selected and the <form> is sent to server-side processing, indeed *ALL* browsers (by specification) then instead send the text of that <option>.

So, from the server-side view of things, in the absence of a value, the text is the value.

So those browsers that do the same thing with the DOM (and it *is* the DOM, not JavaScript, never forget) can be said to simply be emulating normal browser behavior.

Still, it does seem a violation of the tradition of the DOM.

Here's an interesting tidbit: Originally, the *ONLY* browser that allowed you to use formreference.selectName.value was MSIE! Netscape *INSISTED* that you must use form.select[form.select.selectedIndex].value Again, in the original spirit of the DOM, I think Netscape was right. But MSIE prevailed and now all browsers support form.select.value and now we have the ironic situation that all except MSIE have taken the DOM-enhancement one step further.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 01-15-2013, 07:54 PM   PM User | #5
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 454 Times in 452 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
I quite like formreference.selectName.value - I don't really mind about violating the spirit of the DOM or whatever. It seems to me that a select having a raw value is in keeping with other form elements (even though I know that it's not actually the select tag that holds the value but the option tag, but then the select tag is *never* going to have a value, so there is no ambiguity for me).

But then I like to live on the edge. I personally look forward to the day when we can do formreference.selectName.text
xelawho is offline   Reply With Quote
Old 01-15-2013, 08:22 PM   PM User | #6
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,237
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Oh, don't bet me wrong. I'm not going to go back to writing form.select[form.select.selectedIndex].value !!

I did enough of that back in NS 4.7 days.

And I actually like the idea the form.select.value gives me the same thing that the server-side code will see.

But neither can I fault MSIE for *NOT* doing this.

That's what I meant by "on the fence."
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 01-16-2013, 10:47 AM   PM User | #7
jamhead
New to the CF scene

 
Join Date: Jan 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
jamhead is an unknown quantity at this point
Great....it works perfectly with the <option value="">
Thank you all for helping
jamhead is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:43 PM.


Advertisement
Log in to turn off these ads.