Reply to topic
Select Boxes and CFCs
Jason101
Forum Regular

Joined: 14 Mar 2006
Posts: 550
Location: Harrisburg, PA
Reply with quote
Here's a stumping one..

I have a CFC that does a lot of my presentation building, and one of which is a generic function that generates a select box. It takes a few arguments such as the values, the form name, what should be selected and so on..

It builds it fine, but I can't get the value to be selected when it is returned to the browser. The Selected="selected" is in the right place.

Now here's the stumping part. If it take that SAME code via view source, and copy it into the page that is returning the string from the CFC it to the screen, the option is selected. Shocked

This is what is returned from the CFC:

Code:

<select name="CatID" id="CatID">
     <option value=""></option>         
     <option value="1">Test Option</option>         
     <option value="2" selected="selected">Test Option 2</option>         
</select>


Go a head, copy it into a new page and it will be selected, but when it's returned from the CFC it is not. It's almost like the browser is not evaluating the select first to highlight the selected.
Bootstrapping
comprug
Forum Regular

Joined: 15 Feb 2006
Posts: 343
Reply with quote
Jason, this may sound dumb, but check that the markup and closing of your labels is correct. That has caused me hours of misery, often even preventing forms from being filled out. Also, have you tried it in multiple browsers?[/code][/quote]
EDIT
comprug
Forum Regular

Joined: 15 Feb 2006
Posts: 343
Reply with quote
EDIT: Jason, I remember that I ran into this problem too, except in Ruby on Rails... Honestly, I didn't manage to solve it either. I cheated. Cool
Code:
<select name="CatID" id="CatID">
     <option value="" id="Cat"></option>         
     <option value="1" id="Cat1">Test Option</option>         
     <option value="2" id="Cat2">Test Option 2</option>         
</select>
<script type="text/javascript">
document.getElementById("Cat2").setAttribute("selected","selected");
</script>
Re: EDIT
Jason101
Forum Regular

Joined: 14 Mar 2006
Posts: 550
Location: Harrisburg, PA
Reply with quote
comprug wrote:
EDIT: Jason, I remember that I ran into this problem too, except in Ruby on Rails... Honestly, I didn't manage to solve it either. I cheated. Cool
Code:
<select name="CatID" id="CatID">
     <option value="" id="Cat"></option>         
     <option value="1" id="Cat1">Test Option</option>         
     <option value="2" id="Cat2">Test Option 2</option>         
</select>
<script type="text/javascript">
document.getElementById("Cat2").setAttribute("selected","selected");
</script>


AHH! Nice cheat indeed! I will give it a shot.

Thanks!
Shaji


Joined: 21 Feb 2005
Posts: 83
Reply with quote
Jason,

I do not recall syntax.. Should <option value="2" selected="selected">Test Option 2</option> be <option value="2" selected>Test Option 2</option> ?
Jason101
Forum Regular

Joined: 14 Mar 2006
Posts: 550
Location: Harrisburg, PA
Reply with quote
Shaji wrote:
<option value="2" selected>Test Option 2</option> ?


Just having "selected" is not valid XHTML. Selected="select" is proper XHTML. (Although I could be wrong Smile )
Select Boxes and CFCs
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic