Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List box to automatically populate two text boxes

Status
Not open for further replies.

ramnewbietoaccess

Programmer
Nov 4, 2002
52
US
Is it difficult to have a list box (item and price) on a form that would automatically populate a two side by side text boxes on blur? And if not, is it possible to have the onblur find the first available blank text boxes if i have a bunch of rows similar to excel? Im sort of trying to migrate a fairly simple spreadsheet into html. I saved the worksheet as html with functionality but it doesnt edit well and, of course, it doesnt save user forms. Any suggestions? Thanks in advance.
 
Here's an example, although this should be in the JS forum___

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]

<html>
<head>
<title>Untitled</title>

<script language="javascript"><!--
function giveToText(str) {
    var f = document.forms['f'];
    var s = str.split(" - ");
    f.elements['the_price'].value = s[0];
    f.elements['the_item'].value = s[1];
}
--></script>
</head>

<body>

<form name="f">
  <select name="s" onchange="giveToText(this.options[this.selectedIndex].value);">
    <option value="$12.00 - Hotdogs">$12.00 - Hotdogs</option>
    <option value="$15.00 - Baseballs">$15.00 - Baseballs</option>
    <option value="$25.00 - Telephones">$25.00 - Telephones</option>
  </select>
  <br />
  <input type="text" name="the_price" />
  <input type="text" name="the_item" />
</form>

</body>
</html>

*cLFlaVA
----------------------------
[tt]tastes great, less filling.[/tt]
 
thank you very much for everyone's help. i will study this and hope to learn a lot from this list. thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top