Jump to content

Please Help: Form Javascript


DaNuGai

Recommended Posts

Hello,I have a form in which I have a SELECT menu and under the SELECT menu I have (<OPTIONS>) list of all colleges in the United States. Now I ran into a problem yesterday, my form load properly and everything works fine in IE. However, only half of the form load in FireFox and I think its because I have such a big list under SELECT menu. I have this form under a JSP, which is very similar to ASP except JSP uses java.Anyways, I am trying to figure out if it's possible for me to remove SELECT menu and insert a read-only INPUT field, which will be filled automatically from another window. In other words, I will have a link next to the INPUT field, which will open a window with the list of colleges in the United States and upon selecting the college, the popup window will close and the INPUT field will be filled in automatically with the college code.Any help will be greatly appreciated. I have a pretty good feeling that this can be done using JavaScript but I am not sure how, so please help. I am somewhat familiar with XML, so if someone think it's easier to do this with XML, please let me know how.Thanks.

Link to comment
Share on other sites

You want a popup window to display the select menu and when the visitor selects a college from that menu, the popup window will close and the value of the selected college will appear in a read-only text box?If so, you can do that with javascript.If this is the input that you want to populate on the main form:

<input type="text" id="college" readonly="readonly" />

You could have something like this in your popup window:

<select id="collegeSelect">  <option value="college1">College 1</option>  <option value="college2">College 2</option></select><button onclick="choose()">OK</button><script>function choose(){	// First, make sure the window has a parent.	if(window.parent)	{		// Then get a reference to the input element on that parent page.		var collegeText = window.parent.document.getElementById("college");		// If we found that element...		if(collegeText)		{			// Get a reference to the drop down menu.			var select = document.getElementById("collegeSelect");			// It may not be necessary to set the readonly back to false			// in order to set the value of the text input, but we'll do it just in case.			// Once the value is set, set the readonly attribute back to true.			collegeText.readOnly = false;			collegeText.value = select.options[select.selectedIndex].value;			collegeText.readOnly = true;			// And, finally, close this window.			window.close();		}	}}</script>

Link to comment
Share on other sites

  • 5 weeks later...

I was able to fix this issue by a using a popup as described above and transmit the info back to the original page. This took some load off the main window, which fixed the problem. It has been working fine under all browsers and OS except dail-up connect.I have some dial-up connection users that are saying only half of the SELECT drop down menu loads under the pop-up. I am not sure how I can fix this issue. Any help will be greatly appreciated.Thanks.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...