473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Setting FORM value using Javascript

What is supposed to happen:
A user enters data into one of the FORM input selections. When the user submits the form, the onclick
event is supposed to go to a function that will set another FORM value (SearchSel) to some number that
will be used on the next page. The javascript function 'setSelx' doesn't work in FireFox but works with the
other browsers.

Can someone help to fix this code or point me in the right direction?
Server: Win2000, IIS, MSSQL

Expand|Select|Wrap|Line Numbers
  1. <%@ Language="VBScript" %>
  2. <%
  3.  OPTION EXPLICIT 
  4. %>
  5. <!-- #INCLUDE FILE = "./includes/main_conx.asp" -->
  6. <%
  7.     Dim cnnDB
  8.     Set cnnDB = CreateCon
  9. %>
  10. <html lang="en">
  11. <meta http-equiv="Pragma" content="no-cache">
  12. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  13. <head>
  14. <title>Item Master Search</title>
  15. <link rel="stylesheet" type="text/css" href="./stylesheet/default.css">
  16. <script type="text/javascript" src="highlight-active-input.js"></script>
  17. <script language="JavaScript">
  18. function showDiv( id ) { 
  19.     document.getElementById("ItemNo1").value = '';
  20.     document.getElementById("ItemNo2").value = '';
  21.     document.getElementById("Desc1").value = '';
  22.     document.getElementById("DrwNo").value = '';
  23.     document.getElementById("keyword").value = '';
  24.     document.getElementById(id).focus ();
  25. }
  26. function setSel1()
  27.     {    document.getElementById("SearchSel").value = "1";
  28.         return;
  29.     }
  30. function setSel2()
  31.     {    document.getElementById("SearchSel").value = "2";
  32.         return;
  33.     }
  34. function setSel3()
  35.     {    document.getElementById("SearchSel").value = "3";
  36.         return;
  37.     }
  38. function setSel4()
  39.     {    document.getElementById("SearchSel").value = "4";
  40.         return;
  41.     }
  42. function setSel5()
  43.     {    document.getElementById("SearchSel").value = "5";
  44.         return;
  45.     }
  46. </script>
  47. </head>
  48. <body onLoad="document.imageSearch.ItemNo1.focus();">
  49. <div align="center">
  50. <table width="100%" height="90%" border="0" cellspacing="0" cellpadding="0" class="Normal">
  51.  <tr>
  52.   <td valign="top">
  53.   <form action="image_search2.asp" name="imageSearch" method="post" runat="server">
  54.   <input name="SearchSel" type="hidden" value="1">
  55.   <table border="1" align="center" cellspacing="0" class="Normal">
  56.       <tr class="Head1">
  57.         <td colspan="3"><% CALL DisplayCompany %></td>
  58.       </tr>
  59.       <tr class="Head2">
  60.         <td colspan="3">
  61.           <div align="center"> Search ItemMaster </div></td>
  62.       </tr>
  63.       <tr class="Body1">
  64.         <td colspan="3"><div align="Center">Choose a search option below</div></td>
  65.       </tr>
  66.       <tr class="Body1">
  67.         <td width="129">
  68.           <div align="left"> <b>Item Number:</b> </div>        </td>
  69.         <td width="140">(Exact)        </td>
  70.         <td><input name="ItemNo1" id="ItemNo1" type="text" size="30" maxlength="15" onClick="showDiv( 'ItemNo1' ); setSel();"></td>
  71.       <tr class="Body1">
  72.         <td>
  73.           <div align="left"> <b>Item Number:</b> </div>        </td>
  74.         <td>(Contains)        </td>
  75.         <td><input name="ItemNo2" id="ItemNo2" type="text" size="30" maxlength="15" onClick="showDiv( 'ItemNo2' ); setSel2();"></td>
  76.       </tr>
  77.       <tr class="Body1">
  78.         <td>
  79.           <div align="left"> <b>Description:</b> </div>        </td>
  80.         <td>(Contains)        </td>
  81.         <td><input name="Desc1" id="Desc1" type="text" size="30" maxlength="30" onClick="showDiv( 'Desc1' ); setSel3();"></td>
  82.       </tr>
  83.       <tr class="Body1">
  84.         <td>
  85.           <div align="left"> <b>Drawing No:</b> </div>        </td>
  86.         <td>(Contains)        </td>
  87.         <td><input name="DrwNo" id="DrwNo" type="text" size="30" maxlength="15" onClick="showDiv( 'DrwNo' ); setSel4();"></td>
  88.       </tr>
  89.       <tr class="Body1">
  90.         <td colspan="2">
  91.           <div align="left"> <b>Keyword:</b> </div>        </td>
  92.         <td><input name="keyword" id="keyword" type="text" size="30" maxlength="15" onClick="showDiv( 'keyword' ); setSel5();"></td>
  93.       </tr>
  94.   </table>
  95.   <br><br><div align="Center"><input type="submit" name="Submit" value="Submit">
  96.   <input type="reset" name="Submit2" value="Reset"><br><br>
  97. <% Call DisplayFooter() %></div>
  98.   </form>
  99.   </td>
  100.  </tr>
  101. </table>
  102. </div>
  103.    <table width="100%" border="0" cellspacing="0" cellpadding="0">
  104.      <tr>
  105.        <td><% Call DisplayVersion() %></td>
  106.      </tr>
  107.    </table>
  108. <%
  109.     cnnDB.Close
  110. %>
  111. </body>
  112. </html>
  113. <script type="text/javascript">
  114. <!--
  115.   initInputHighlightScript();
  116. //-->
  117. </script>
  118.  
Mar 16 '07 #1
5 2476
acoder
16,027 Expert Mod 8TB
Welcome to TSDN.

You haven't given an id to SearchSel. Also, where are you calling the setSelx functions?
Mar 19 '07 #2
Sorry if I didn't make it clear. When I mentioned 'setSelx', the 'x' part is an actual numeric number depending on which 'onclick' input were talkin about.

This is an example of how I am trying to call one of the events:

<input name="ItemNo2" id="ItemNo2" type="text" size="30" maxlength="15" onClick="showDiv( 'ItemNo2' ); setSel2();">

I also did try setting an ID but had no luck with FireFox. As I said, the way this code is now, it works like it should with IE and Opera, just not FireFox.
Sorry, I'm a newbie at this. I did try to find some help doing some google searches but didn't have much luck.

Jose
Mar 19 '07 #3
acoder
16,027 Expert Mod 8TB
Yes, I did realise that. Now I've noticed your setSelx functions (after scrolling to the right).

In your code, you need to set an id to the hidden element. So
[HTML]<input name="SearchSel" type="hidden" value="1">[/HTML]
becomes
[HTML]<input id="SearchSel" name="SearchSel" type="hidden" value="1">[/HTML]
Mar 20 '07 #4
Thanks acoder! That worked great. Such a simple thing was missed and I just didn't see it.

Jose
Mar 20 '07 #5
acoder
16,027 Expert Mod 8TB
You're welcome.
Mar 20 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Colin Colin | last post by:
I downloaded a calendar.asp file that someone named Jacob "WickedPisser" Gilley made. It's a few years old but It works fine and it's what I was looking for without getting into ActiveX objects. ...
2
by: J Krugman | last post by:
I have a form with a couple of submit buttons, plus a "pseudolink" that is also supposed to submit the form; the submitted form data feeds to a CGI script. The two submit buttons have the name...
12
by: daniel kaplan | last post by:
Hi All, Been learning Javascript (via google) to create forms with pre-set values. As seen below. My problem I have found is this: I can't seem to figure out (or find so far via google) how to...
3
by: Bob | last post by:
I'm a total newbie at Javascript, but a programmer for over 20 years... so, my plans may be bigger than they are possible. I'm trying to set with Javascript the value of a form field... easy...
21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
12
by: CLEAR-RCIC | last post by:
Hi, I'm having problems setting focus to a textbox on a web user contol on an asp.net web page. The following script works on normal asp.net pages: <script language="javascript"> function...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
8
by: Efi Merdler | last post by:
Hi, In my code I'm doing some xml transformation, at the end I receive a fully transformed html file. I'm setting the Value property of an hidden field control to have the content of this html...
1
by: RobertTheProgrammer | last post by:
Hi all, I have a perplexing problem here. I've developed some software using ASP.NET with C# in the code behind. I've been setting the "window.defaultStatus" in the code behind to send messages...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.