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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a problem wtih a javascript

Status
Not open for further replies.

LTillner

MIS
Apr 23, 2002
96
US
I have a problem wtih a javascript that is embedded in a cgi/perl script (DBMan) file: The javascript works, but for some reason, the data is not saved in the database (well, flat file). Here are pertinent snipits of code:


In my Script (sub html_page_top, sub html_error_page_top and sub html_imp_preview):
function init(frm) {
var combo = frm.Select_Box;
var combo2 = frm.Category;
frm.category.value = combo.options[combo.selectedIndex].value;
frm.occupancytype.value = combo2.options[combo2.selectedIndex].value;
}


In my sub html_imp_record_form code:

<SELECT NAME=&quot;Select_Box&quot; onChange=&quot;fillSelectFromArray(this.form.Category, ((this.selectedIndex == -1) ? null : team[this.selectedIndex-1]));&quot;>
<OPTION VALUE=&quot;-1&quot;>Select Category
<OPTION VALUE=&quot;Site Improvements-Retaining Wall&quot;>Site Improvements - Retaining Wall
<OPTION VALUE=&quot;Site Improvements-Culvert&quot;>Site Improvements - Culvert
<OPTION VALUE=&quot;Site Improvements-Curbing&quot;>Site Improvements - Curbing
<OPTION VALUE=&quot;Site Improvements-Flagpole&quot;>Site Improvements - Flagpole
<OPTION VALUE=&quot;Site Improvements-Fencing&quot;>Site Improvements - Fencing
<OPTION VALUE=&quot;Site Improvements-Grating&quot;>Site Improvements - Grating
<OPTION VALUE=&quot;Site Improvements-Landscaping&quot;>Site Improvements - Landscaping
<OPTION VALUE=&quot;Site Improvements-Miscellaneous&quot;>Site Improvements - Miscellaneous
<OPTION VALUE=&quot;Site Improvements-Parking Lot&quot;>Site Improvements - Parking Lot
<OPTION VALUE=&quot;Site Improvements-Paving&quot;>Site Improvements - Paving
<OPTION VALUE=&quot;Site Improvements-Sprinklers&quot;>Site Improvements - Sprinklers
<OPTION VALUE=&quot;Site Improvements-Stairway/Deck&quot;>Site Improvements - Stairway/Deck
<OPTION VALUE=&quot;Site Improvements-Swimming Pool&quot;>Site Improvements - Swimming Pool
<OPTION VALUE=&quot;Site Improvements-Synthetic Surface&quot;>Site Improvements - Synthetic Surface
<OPTION VALUE=&quot;Site Improvements-Tennis Court&quot;>Site Improvements - Tennis Court
<OPTION VALUE=&quot;Other&quot;>Other
</SELECT><br>&nbsp;
<SELECT NAME=&quot;Category&quot; SIZE=&quot;1&quot;>
<OPTION> </OPTION>
</SELECT></TD></TR>


In my sub html_imp_add_form (and other places) code:
print qq|
<form action=&quot;$db_script_url&quot; method=&quot;POST&quot; name=&quot;form1&quot; onsubmit=&quot;init(this)&quot;>
<input type=hidden name=&quot;db&quot; value=&quot;$db_setup&quot;>
<input type=hidden name=&quot;uid&quot; value=&quot;$db_uid&quot;>
<input type=hidden name=&quot;category&quot; value=&quot;&quot;>
<input type=hidden name=&quot;occupancytype&quot; value=&quot;&quot;>

|;


The following is a link to a test version of the html.pl (named htmimp_pl.txt):



a sample of the working script (outside of DBMan) is at:



I really need help figuring out what I've done that this code no longer writes to the fields in the file. The first select box puts a &quot;-1&quot; in the database, the options list puts nothing in the database -- it was working at one time too! now it's not!

Thanks for your help!
Lynette
 
Without seeing the rest of your javascript or your cgi script, it would appear that the problem is in the onchange event of your select box. It looks like you might be trying to assign a value if one thing happens, otherwise another value. In each case, you're assigning it the value of -1. Might be worth checking out...




There's always a better way...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top