Jump to content

Forcing a <select> to show the selectedIndex


Rottingham

Recommended Posts

Hello all,

 

I have a list of people in a select box that is for adding family members to a family in my application. The code determines if the persons last name matches the last name of the family they are being added to. If so, it makes the <option selected>. This works fine, and the line is selected, however, it does not force the select list to make that option visible.

 

I.e. If its the 50th person in the list, you still have to scroll down to see it. This is frustrating and so far I haven't found a good way to change it. Does anyone have an idea? I've tried using a javascript code to set the .selectedIndex and that didn't seem to do it.

 

Here is the code for making it selected:

/	Conveniently select this item if the last name matched the name of the head
		if(!strcmp($child_last,$head->get_field("Last")))
			$child_options .= "<option value=\"$child_id\" selected>$child_last, $child_first</option>\n";
		else
			$child_options .= "<option value=\"$child_id\">$child_last, $child_first</option>\n";

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.