JavaScript - Need Help Getting Result To Display Under Textbox
Hello ! I am trying to create an auto suggest drop down.
I have some ASP and Javascript code that I am using as an Autosuggest. Trouble is, the result displays on the main page, not under the text box like a drop down menu. I need help in getting the results to display correctly underneath the textbox. I have trawlled the internet and have loads and loads of code samples but I cant see the wood for the trees and I am really struggling with editing this code so that it displays correctly. clienthint.asp Code: <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <html> <head> <script src="clienthint.js"></script> </head> <body> <% 'this displays the value of the textbox after the form is submitted If trim(Request("txt1")) <> "" Then Response.Write "You entered:" Response.Write "<b>" & Request("txt1") & "</b><br /><br />" End If %> <form name="form1" action="clienthint.asp" method="post"> Enter Word: <input type="text" name="txt1" id="txt1" onKeyUp="showHint(this.value,'txt1','form1',true)"> <input type="submit" name="submit" value="submit"> </form> <p>Suggestions: <span id="txtHint"></span></p> </body> </html> clienthint.js Code: var xmlHttp function showHint(str, box, thisForm, autoSubmit) { if (str.length==0) { document.getElementById("txtHint").innerHTML=""; return; } xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="gethint.asp"; url=url+"?q="+str; url=url+"&b="+box; url=url+"&f="+thisForm; url=url+"&a="+autoSubmit; url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function stateChanged() { if (xmlHttp.readyState==4) { document.getElementById("txtHint").innerHTML=xmlHttp.responseText; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } //this function allows for Clickable suggestions function setTextBox(thisText,thisBox,thisForm,autoSubmit){ document.getElementById(thisBox).value = thisText //this autoSubmits the form after a suggestion is clicked - it is not working :( //if(autoSubmit=='true'){ // alert(thisForm); // document.getElementById(thisForm).submit(); //} } gethint.asp Code: <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% response.expires=-1 Dim rsWords Dim rsWords_numRows Dim q Dim b Dim hint q=ucase(request.querystring("q")) b=(request.querystring("b")) f=(request.querystring("f")) a=(request.querystring("a")) hint="" Set rsWords = Server.CreateObject("ADODB.Recordset") rsWords.ActiveConnection = "Provider=SQLOLEDB; Data Source=JAGUAR\SQLEXPRESS; Initial Catalog=67625252; User ID=SFSDFSDF; Password=KJHSDHFJHDF" rsWords.Source = "SELECT * FROM Rmatable WHERE (RMA_ID LIKE'" + q + "%') ORDER BY RMA_ID" rsWords.CursorType = 2 rsWords.CursorLocation = 2 rsWords.LockType = 3 rsWords.Open() rsWords_numRows = 0 If Not rsWords.EOF Then Do While Not rsWords.EOF If trim(hint) = "" Then hint = "<a href=""javascript:setTextBox('" & rsWords("RMA_ID") & "','" & b & "','" & f & "','" & a & "');"">" & rsWords("RMA_ID") & "</a>" Else hint = hint & " , <a href=""javascript:setTextBox('" & rsWords("RMA_ID") & "','" & b & "','" & f & "','" & a & "');"">" & rsWords("RMA_ID") & "</a>" End If rsWords.MoveNext() Loop End If if trim(hint)="" then response.write("no suggestion") else response.write(hint) end if rsWords.Close() Set rsWords = Nothing %> Similar TutorialsCan anyone tell me what I am doing wrong? I am a javascript student and I am building a calculator. The display on the calculator will not show the numbers when the button is selected. I am inserting my javaScript and html: <html> <head> <title> Calculator</title> </head> <script type = "text/javascript" src="calculator.js"></script> <body> <center>Calculator<br> To use this calculator, CLICK a number, then an ACTION, then another number, then the EQUALS button. <br> Press "C" when ready to start over. <br> The "N" button makes your previous number a negative.<br></center> <form name="calculator"> <table border = "1" align ="center"> <tr> <td ><input type = "text" size = 26 name = "display" id = ""/></td> </tr> <tr ><br /> <!-- first row of calculator --> <td> <input type = "button" value = " 7 " id = "" onclick="newstring('7')"> <input type = "button" value = " 8 " id = "" onclick="newstring('8')"/> <input type = "button" value = " 9 " id = "" onclick="newstring('9')"> <input type = "button" value = " / " id = "" onclick="newstring('/')"> </td> </tr> <tr ><br /> <!-- second row of calculator --> <td> <input type = "button" value = " 4 " id = "" onclick="newstring('4')"> <input type = "button" value = " 5 " id = "" onclick="newstring('5')"> <input type = "button" value = " 6 " id = "" onclick="newstring('6')"> <input type = "button" value = " * " id = "" onclick="newstring('*')"> </td> </tr> <tr ><br /> <!-- third row of calculator --> <td> <input type = "button" value = " 1 " id = "" onclick="newstring('1')"> <input type = "button" value = " 2 " id = "" onclick="newstring('2')"> <input type = "button" value = " 3 " id = "" onclick="newstring('3')"> <input type = "button" value = " - " id = "" onclick="newstring('-')"> </td> </tr> <tr ><br /> <!-- forth row of calculator --> <td> <input type = "button" value = " 0 " id = "" onclick="newstring('0')"> <input type = "button" value = " N " id = "" onclick="newstring('N')"> <input type = "button" value = " = " id = "" onclick="newstring('=')"> <input type = "button" value = " + " id = "" onclick="newstring('+')"> </td> </tr> <tr ><br /> <!-- fifth row of calculator --> <td> <input type = "button" value = "   " id = ""> <input type = "button" value = "   " id = ""> <input type = "button" value = "   " id = ""> <input type = "button" value = " C " id = "" onclick="clear()"> </td> </tr> </table> </body> </form> </html> ############################################### javascript: memory = "0"; current = "0"; operation =0; function newstring(digit) { if (eval(current) == 0) { current = digit; } else { current = current + digit; } document.calculator.display.value=current; } Hi Folks, Have a C# application. On one of the .aspx page, I have a simple textbox: <asp:TableCell ColumnSpan="4"> <asp:TextBox ID="txtBox1" runat="server" Width="210px" MaxLength="100" TextMode="MultiLine" /></asp:TableCell> The Textbox display about half of its 100 character capacity to the user. I need the Tooltip to display the entire contents when hovered. Since the user can enter any length of text and hover the tooltip at any time, I figure Javascript in the codebehind page (.aspx.cs ) would be the solution. I know absolutley nothing about JAVA script ! Can anyone help ? Thank You in advance for your help ! Hi.. I have syntax for autocalculate the max lot and the output display in Total_max same with min lot and the output display in Totam_min, now I need to have convert automatically the number I was inputted in max lot textbox and it will display in max doz textbox same also with min lot convert to min doz textbox. the conversion is: max doz = max lot * 10 min doz = min lot * 10 here is my code: Code: <html> <head> <link rel="stylesheet" type="text/css" href="kanban.css" /> <script type="text/javascript"> function display_PS(){ document.loading_kanban.action="ParameterSettings.php"; document.loading_kanban.submit(); } function display_Kanban(){ document.loading_kanban.action="kanban_report.php"; document.loading_kanban.submit(); } </script> <script type="text/javascript"> //Code for auto calculate Total Max// function autocalearn(oText) { if (isNaN(oText.value)) //filter input { alert('Numbers only!'); oText.value = ''; } var field, val, oForm = oText.form, Total_max = a = 0; for (a; a < arguments.length; ++a) //loop through text elements { field = arguments[a]; val = parseFloat(field.value); //get value if (!isNaN(val)) //number? { Total_max += val; //accumulate } } oForm.Total_max.value = Total_max.toFixed(2); //out } </script> <script type="text/javascript"> //Code for auto calculate Total Min// function autocalmin(oText) { if (isNaN(oText.value)) //filter input { alert('Numbers only!'); oText.value = ''; } var field, val, oForm = oText.form, Total_min = a = 0; for (a; a < arguments.length; ++a) //loop through text elements { field = arguments[a]; val = parseFloat(field.value); //get value if (!isNaN(val)) //number? { Total_min += val; //accumulate } } oForm.Total_min.value = Total_min.toFixed(2); //out } </script> </head> <form name="loading_kanban"> <div id="main_button"> <center> <!--<label style="margin-left: .9em; font-family: Arial, Helvetica, sans-serif; font-size: .7em;">Display Details:</label><input onclick='showDetails(this);' id='chkDetail' type='checkbox' checked='checked' value='wip'/> --> <input type="button" name="parameter_settings" value="Parameter Settings" onclick="display_PS()"> <input type="button" name="parameter_settings" value="Stock Requisition"> <input type="button" name="parameter_settings" value="Kanban Report" onclick="display_Kanban()"> </center> </div> <div id="fieldset_PS"> <center> <table border="1"> <th>Compounds</th> <th>Max</th> <th>UOM</th> <th>Max</th> <th>UOM</th> <th>Min</th> <th>UOM</th> <th>Min</th> <th>UOM</th> <tr> <td><label id="P27" name="P27" size="6" style="text-align: center;">P27</label></td> <td><input type="text" name="P27_max" id="P27_max" size="6" onkeyup="return autocalearn(this, P28_max, P30_max, P32W_max, P33_max, P35_max, P35M_max, P35W_max, P38_max, P41_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td> <td><label id="P27LOT_max" name="P27LOT_max" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P27_maxdoz" id="P27_maxdoz" size="6"></td> <td><label id="P27Doz_max" name="P27Doz_max" size="3" style="text-align: left;">Doz</label></td> <td><input type="text" name="P27_min" id="P27_min" size="6" onkeyup="return autocalmin(this, P28_min, P30_min, P32W_min, P33_min, P35_min, P35M_min, P35W_min, P38_min, P41_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td> <td><label id="P27LOT_min" name="P27LOT_min" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P27_mindoz" id="P27_mindoz" size="6"></td> <td><label id="P27Doz_min" name="P27Doz_min" size="3" style="text-align: left;">Doz</label></td> </tr> <tr> <td><label id="P28" name="P28" size="6">P28</label></td> <td><input type="text" name="P28_max" id="P28_max" size="6" onkeyup="return autocalearn(this, P27_max, P30_max, P32W_max, P33_max, P35_max, P35M_max, P35W_max, P38_max, P41_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td> <td><label id="P28LOT_max" name="P28LOT_max" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P28_maxdoz" id="P28_maxdoz" size="6"></td> <td><label id="P28Doz_max" name="P28Doz_max" size="3" style="text-align: left;">Doz</label></td> <td><input type="text" name="P28_min" id="P28_min" size="6" onkeyup="return autocalmin(this, P27_min, P30_min, P32W_min, P33_min, P35_min, P35M_min, P35W_min, P38_min, P41_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td> <td><label id="P28LOT_min" name="P28LOT_min" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P28_mindoz" id="P28_mindoz" size="6"></td> <td><label id="P28Doz_min" name="P28Doz_min" size="3" style="text-align: left;">Doz</label></td> </tr> <tr> <td><label id="P30" name="P30" size="6">P30</label></td> <td><input type="text" name="P30_max" id="P30_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P32W_max, P33_max, P35_max, P35M_max, P35W_max, P38_max, P41_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td> <td><label id="P30LOT_max" name="P30LOT_max" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P30_maxdoz" id="P30_maxdoz" size="6"></td> <td><label id="P30Doz_max" name="P30Doz_max" size="3" style="text-align: left;">Doz</label></td> <td><input type="text" name="P30_min" id="P30_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P32W_min, P33_min, P35_min, P35M_min, P35W_min, P38_min, P41_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td> <td><label id="P30LOT_min" name="P30LOT_min" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P30_mindoz" id="P30_mindoz" size="6"></td> <td><label id="P30Doz_min" name="P30Doz_min" size="3" style="text-align: left;">Doz</label></td> </tr> <tr> <td><label id="P32W" name="P32W" size="6">P32W</label></td> <td><input type="text" name="P32W_max" id="P32W_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P33_max, P35_max, P35M_max, P35W_max, P38_max, P41_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td> <td><label id="P32WLOT_max" name="P32WLOT_max" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P32W_maxdoz" id="P32W_maxdoz" size="6"></td> <td><label id="P32WDoz_max" name="P32WDoz_max" size="3" style="text-align: left;">Doz</label></td> <td><input type="text" name="P32W_min" id="P32W_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P33_min, P35_min, P35M_min, P35W_min, P38_min, P41_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td> <td><label id="P32WLot_min" name="P32WLot_min" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P32W_mindoz" id="P32W_mindoz" size="6"></td> <td><label id="P32WDoz_min" name="P32WDoz_min" size="3" style="text-align: left;">Doz</label></td> </tr> <tr> <td><label id="P33" name="P33" size="6">P33</label></td> <td><input type="text" name="P33_max" id="P33_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P35_max, P35M_max, P35W_max, P38_max, P41_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td> <td><label id="P33LOT_max" name="P33LOT_max" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P33_maxdoz" id="P33_maxdoz" size="6"></td> <td><label id="P33Doz_max" name="P33Doz_max" size="3" style="text-align: left;">Doz</label></td> <td><input type="text" name="P33_min" id="P33_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P35_min, P35M_min, P35W_min, P38_min, P41_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td> <td><label id="P33LOT_min" name="P33LOT_min" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P33_mindoz" id="P33_mindoz" size="6"></td> <td><label id="P33Doz_min" name="P33Doz_min" size="3" style="text-align: left;">Doz</label></td> </tr> <tr> <td><label id="P35" name="P35" size="6">P35</label></td> <td><input type="text" name="P35_max" id="P35_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P33_max, P35M_max, P35W_max, P38_max, P41_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td> <td><label id="P35LOT_max" name="P35LOT_max" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P35_maxdoz" id="P35_maxdoz" size="6"></td> <td><label id="P35Doz_max" name="P35Doz_max" size="3" style="text-align: left;">Doz</label></td> <td><input type="text" name="P35_min" id="P35_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P33_min, P35M_min, P35W_min, P38_min, P41_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td> <td><label id="P35LOT_min" name="P35LOT_min" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P35_mindoz" id="P35_mindoz" size="6"></td> <td><label id="P35Doz_min" name="P35Doz_min" size="3" style="text-align: left;">Doz</label></td> </tr> <tr> <td><label id="P35M" name="P35M" size="6">P35M</label></td> <td><input type="text" name="P35M_max" id="P35M_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P33_max, P35_max, P35W_max, P38_max, P41_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td> <td><label id="P35MLOT_max" name="P35MLOT_max" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P35M_maxdoz" id="P35M_maxdoz" size="6"></td> <td><label id="P35MDoz_max" name="P35MDoz_max" size="3" style="text-align: left;">Doz</label></td> <td><input type="text" name="P35M_min" id="P35M_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P33_min, P35_min, P35W_min, P38_min, P41_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td> <td><label id="P35MLOT_min" name="P35MLOT_min" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P35M_mindoz" id="P35M_mindoz" size="6"></td> <td><label id="P35MDoz_min" name="P35MDoz_min" size="3" style="text-align: left;">Doz</label></td> </tr> <tr> <td><label id="P35W" name="P35W" size="6">P35W</label></td> <td><input type="text" name="P35W_max" id="P35W_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P33_max, P35_max, P38_max, P41_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td> <td><label id="P35WLOT_max" name="P35WLOT_max" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P35W_maxdoz" id="P35W_maxdoz" size="6"></td> <td><label id="P35WDoz_max" name="P35WDoz_max" size="3" style="text-align: left;">Doz</label></td> <td><input type="text" name="P35W_min" id="P35W_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P33_min, P35_min, P38_min, P41_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td> <td><label id="P35WLOT_min" name="P35WLOT_min" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P35W_mindoz" id="P35W_mindoz" size="6"></td> <td><label id="P35WDoz_min" name="P35WDoz_min" size="3" style="text-align: left;">Doz</label></td> </tr> <tr> <td><label id="P38" name="P38" size="6">P38</label></td> <td><input type="text" name="P38_max" id="P38_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P33_max, P35_max, P35M_max, P35W_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td> <td><label id="P38LOT_max" name="P38LOT_max" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P38_maxdoz" id="P38_maxdoz" size="6"></td> <td><label id="P38Doz_max" name="P38Doz_max" size="3" style="text-align: left;">Doz</label></td> <td><input type="text" name="P38_min" id="P38_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P33_min, P35_min, P35M_min, P35W_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td> <td><label id="P38LOT_min" name="P38LOT_min" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P38_mindoz" id="P38_mindoz" size="6"></td> <td><label id="P38Doz_min" name="P38Doz_min" size="3" style="text-align: left;">Doz</label></td> </tr> <tr> <td><label id="P41" name="P41" size="6">P41</label></td> <td><input type="text" name="P41_max" id="P41_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P33_max, P35_max, P35M_max, P35W_max, P38_max, P42_max, P43_max, P45_max, P46_max, P47_max)"></td> <td><label id="P41LOT_max" name="P41LOT_max" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P41_maxdoz" id="P41_maxdoz" size="6"></td> <td><label id="P41Doz_max" name="P41Doz_max" size="3" style="text-align: left;">Doz</label></td> <td><input type="text" name="P41_min" id="P41_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P33_min, P35_min, P35M_min, P35W_min, P38_min, P42_min, P43_min, P45_min, P46_min, P47_min)"></td> <td><label id="P41LOT_min" name="P41LOT_min" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P41_mindoz" id="P41_mindoz" size="6"></td> <td><label id="P41Doz_min" name="P41Doz_min" size="3" style="text-align: left;">Doz</label></td> </tr> <tr> <td><label id="P42" name="P42" size="6">P42</label></td> <td><input type="text" name="P42_max" id="P42_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P33_max, P35_max, P35M_max, P35W_max, P38_max, P41_max, P43_max, P45_max, P46_max, P47_max)"></td> <td><label id="P42LOT_max" name="P42LOT_max" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P42_maxdoz" id="P42_maxdoz" size="6"></td> <td><label id="P42Doz_max" name="P42Doz_max" size="3" style="text-align: left;">Doz</label></td> <td><input type="text" name="P42_min" id="P42_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P33_min, P35_min, P35M_min, P35W_min, P38_min, P41_min, P43_min, P45_min, P46_min, P47_min)"></td> <td><label id="P42LOT_min" name="P42LOT_min" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P42_mindoz" id="P42_mindoz" size="6"></td> <td><label id="P42Doz_min" name="P42Doz_min" size="3" style="text-align: left;">Doz</label></td> </tr> <tr> <td><label id="P43" name="P43" size="6">P43</label></td> <td><input type="text" name="P43_max" id="P43_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P33_max, P35_max, P35M_max, P35W_max, P38_max, P41_max, P42_max, P45_max, P46_max, P47_max)"></td> <td><label id="P43LOT_max" name="P43LOT_max" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P43_maxdoz" id="P43_maxdoz" size="6"></td> <td><label id="P43Doz_max" name="P43Doz_max" size="3" style="text-align: left;">Doz</label></td> <td><input type="text" name="P43_min" id="P43_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P33_min, P35_min, P35M_min, P35W_min, P38_min, P41_min, P42_min, P45_min, P46_min, P47_min)"></td> <td><label id="P43LOT_min" name="P43LOT_min" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P43_mindoz" id="P43_mindoz" size="6"></td> <td><label id="P43Doz_min" name="P43Doz_min" size="3" style="text-align: left;">Doz</label></td> </tr> <tr> <td><label id="P45" name="P45" size="6">P45</label></td> <td><input type="text" name="P45_max" id="P45_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P33_max, P35_max, P35M_max, P35W_max, P38_max, P41_max, P42_max, P43_max, P46_max, P47_max)"></td> <td><label id="P45LOT_max" name="P45LOT_max" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P45_maxdoz" id="P45_maxdoz" size="6"></td> <td><label id="P45Doz_max" name="P45Doz_max" size="3" style="text-align: left;">Doz</label></td> <td><input type="text" name="P45_min" id="P45_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P33_min, P35_min, P35M_min, P35W_min, P38_min, P41_min, P42_min, P43_min, P46_min, P47_min)"></td> <td><label id="P45LOT_min" name="P45LOT_min" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P45_mindoz" id="P45_mindoz" size="6"></td> <td><label id="P45Doz_min" name="P45Doz_min" size="3" style="text-align: left;">Doz</label></td> </tr> <tr> <td><label id="P46" name="P46" size="6">P46</label></td> <td><input type="text" name="P46_max" id="P46_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P33_max, P35_max, P35M_max, P35W_max, P38_max, P41_max, P42_max, P43_max, P45_max, P47_max)"></td> <td><label id="P46LOT_max" name="P46LOT_max" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P46_maxdoz" id="P46_maxdoz" size="6"></td> <td><label id="P46Doz_max" name="P46Doz_max" size="3" style="text-align: left;">Doz</label></td> <td><input type="text" name="P46_min" id="P46_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P33_min, P35_min, P35M_min, P35W_min, P38_min, P41_min, P42_min, P43_min, P45_min, P47_min)"></td> <td><label id="P46LOT_min" name="P46LOT_min" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P46_mindoz" id="P46_mindoz" size="6"></td> <td><label id="P46Doz_min" name="P46Doz_min" size="3" style="text-align: left;">Doz</label></td> </tr> <tr> <td><label id="P47" name="P47" size="6">P47</label></td> <td><input type="text" name="P47_max" id="P47_max" size="6" onkeyup="return autocalearn(this, P27_max, P28_max, P30_max, P32W_max, P33_max, P35_max, P35M_max, P35W_max, P38_max, P41_max, P42_max, P43_max, P45_max, P46_max)"></td> <td><label id="P47LOT_max" name="P47LOT_max" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P47_maxdoz" id="P47_maxdoz" size="6"></td> <td><label id="P47Doz_max" name="P47Doz_max" size="3" style="text-align: left;">Doz</label></td> <td><input type="text" name="P47_min" id="P47_min" size="6" onkeyup="return autocalmin(this, P27_min, P28_min, P30_min, P32W_min, P33_min, P35_min, P35M_min, P35W_min, P38_min, P41_min, P42_min, P43_min, P45_min, P46_min)"></td> <td><label id="P47LOT_min" name="P47LOT_min" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="P47_mindoz" id="P47_mindoz" size="6"></td> <td><label id="P47Doz_min" name="P47Doz_min" size="3" style="text-align: left;">Doz</label></td> </tr> <tr> <td><label id="Total" name="Total" size="6"><b>Total</b><label></td> <td><input type="text" name="Total_max" id="Total_max" size="6"></td> <td><label id="TotalLOT_max" name="TotalLOT_max" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="Total_maxdoz" id="Total_maxdoz" size="6"></td> <td><label id="TotalDoz_max" name="TotalDoz_max" size="3" style="text-align: left;">Doz</label></td> <td><input type="text" name="Total_min" id="Total_min" size="6"></td> <td><label id="TotalLOT_min" name="TotalLOT_min" size="3" style="text-align: left;">Lot</label></td> <td><input type="text" name="Total_mindoz" id="Total_mindoz" size="6"></td> <td><label id="TotalDoz_min" name="TotalDoz_min" size="3" style="text-align: left;">Doz</label></td> </tr> </table> </center> </div> <div id="footer_button"> <input type="button" name="SAVE" value="SAVE" style="width: 25%;"> <input type="button" name="CANCEL" value="CANCEL"> </div> </form> </html> I attach the sample imge of my webpage. I have a long list consisting of a name and associated number, like this: SITE01 2111 SITE02 4567 SITE03 5555 and so on. I would like to put two dropdown boxes where the user can select either the name or the number. Then based upon the users selection have both the name and number appear. I'm thinking of putting all the data in an array and using the dropdowns to query the array. That sounds good but I'm new to javascript and a detailed example of how to do this would be needed, if its even the right approach to take to accomplish this. Good day to you all, I'm working on a form which would display the result in the same div that the form is. Here is my code so far: PHP Code: <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <textarea name="html"></textarea><br /> <input type="submit" onclick="load('<?php echo $_SERVER['PHP_SELF']; ?>','page');"/><br /> </form> Preview:<br /> <?php if(isset($_POST['html'])) echo stripslashes($_POST['html']); ?> <script type="text/javascript"> function ahah(url, target) { document.getElementById(target).innerHTML = ' Fetching data...'; if (window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } if (req != undefined) { req.onreadystatechange = function() {ahahDone(url, target);}; req.open("GET", url, true); req.send(""); } } function ahahDone(url, target) { if (req.readyState == 4) { // only if req is "loaded" if (req.status == 200) { // only if "OK" document.getElementById(target).innerHTML = req.responseText; } else { document.getElementById(target).innerHTML=" Error:\n"+ req.status + "\n" +req.statusText; } } } function load(name, div) { ahah(name,div); return false; } </script> My problem is when I click on the button , the text in my text area don't show. Can somebody help me. Thanks! When I hit the submit button, the result are display on a new page. how do I force it to stay on the same page, here's my code. Code: <HTML> <HEAD> <TITLE>Test Input</TITLE> <script type="text/javascript"> function addtext() { var newtext = document.myform.inputbox.value; document.writeln(newtext); } </script> </HEAD> <BODY> <FORM NAME="myform">Enter something in the box: <BR> <INPUT TYPE="text" NAME="inputbox" VALUE=""> <INPUT TYPE="button" NAME="button" Value="Check" onClick="addtext()"> </FORM> </BODY> </HTML> any comments or suggestions would be greatly appreciated. hi this is santosh first off all thanks in advance to all who r reading my question im in prblm in my project in 1 file i have to first display textbox in html statically which will hav + & - button preceding it , & on click of + button one more textbox should appear dynamically & first textbox + button should disapper & it should hav only - button & the textbox which was dynamically generated now on click of first textbox + button should hav + & - button & it should go on. & on click of - button textbox which is in front of it should get deleted. here i tried alot but my code is showing + & - button to every textbox that is dynamically generated which is not the requirement plz help me im in great need. earlier also i hav submitted my queries & got a fully satisfied result bcoz of that now im having great hopes from u & this site plz reply as early as possible waiting for ur reply again thanks in advance Hello! I am working on creating a basic calorie calculator with Javascript and my code is not showing the results after the user makes their selections. I've created a simple function to obtain the user's weight, activity and duration info but when I use the GetElementById to retrieve the result, it does not show up. Any help would be much appreciated to make this work. Thanks. Code: <head> <script type="text/javascript"> var myActivity = new Array(); myActivity[100] = "6.670"; myActivity[200] = "3.811"; myActivity[300] = "3.343"; myActivity[400] = "3.343"; myActivity[500] = "3.343"; myActivity[600] = "4.765"; myActivity[700] = "4.765" function CalorieBurner() { //user prompt var caloriesBurned; var myForm = document.form; //processing var caloriesBurned = (myForm.duration[formElement.value] * (myActivity[formElement.value] * 3.5 * myForm.weight[formElement.value])/200); FormElement = myForm.activity[myForm.activity.selectedIndex]; document.getElementById("caloriesBurned").innerHTML = "You will burn " + caloriesBurned + "calories doing " + myForm.duration[formElement.value] + "minutes of " + FormElement.text; } </script> </head> <body> <form name="form"> Enter your weight: <input type="text" name="weight" /> <br /><br /> Select an activity: <br /> <select name="activity"> <option value="100"> Backpacking, Hiking with pack </option> <option value="200"> Bagging grass, leaves </option> <option value="300"> Bathing dog </option> <option value="400"> Carpentry, general</option> <option value="500"> Carrying infant, level ground </option> <option value="600"> Carrying infant, upstairs </option> <option value="700"> Children's games, hopscotch... </option> </select> <br /><br /><br /> Enter the duration of your activity (in minutes): <input type="text" name="duration" /> </form> <br /><br /><br /> <input type="button" value="Results" name="btnUpdate" onClick="CalorieBurner()"/> <br /><br /><br /> <div id="caloriesBurned"></div> </body> </html> Hi friends, i have xnl file like <DATAPACKET > <data1> <R_ID>101</R_ID> <R_PRE>38</R_PRE> <R_PRE2>39</R_PRE2> <R_TEMP>8.35</R_TEMP> <R_TENP2>0.64</R_TENP2> </data1> <data1> <R_ID>102</R_ID> <R_PRE>36</R_PRE> <R_PRE2>37</R_PRE2> <R_TEMP>7.23</R_TEMP> <R_TENP2>1.21</R_TENP2> </data1> <data1> <R_ID>103</R_ID> <R_PRE>34</R_PRE> <R_PRE2>36</R_PRE2> <R_TEMP>7.21</R_TEMP> <R_TENP2>1.95</R_TENP2> </data1> <data1> <R_ID>104</R_ID> <R_PRE>32</R_PRE> <R_PRE2>35</R_PRE2> <R_TEMP>6.25</R_TEMP> <R_TENP2>2.30</R_TENP2> </data1> <data1> <DATAPACKET > then i have textbox...when i type 101 its go and get all data in the row in text area like 101 32 6025 2.30 please give me any idea how to do this i m try this if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET", "Refrigerater.xml", false); xmlhttp.send(); xmlDoc = xmlhttp.responseXML; x = xmlDoc.getElementsByTagName("ROWDATA"); //x = xmlDoc.getElementsByTagName("data1"); function displayInfo(selBox) { x = xmlDoc.getElementsByTagName("ROWDATA"); var col = (selBox.options[selBox.selectedIndex].text); document.getElementById("show").innerHTML = " " + col; } Please resolve my problem Thanks Venkat.S Hi, i will try to be as brief as possible. I have a page A with form: Code: <form id="search" action="find.html" method="get"> ... (some select options) ... <input type="submit" class="submit" value="search"> this form look up some holiday destination which appears on this page with url: (example) Code: www.domain.com/find.html?destination=italy&price=500 Now, I dont want to display result on this page, but on page B, in iframe. I found a way how to redirect output as a link to properly show in iframe on page B. Page A contains: Code: <a href="pageb.html?http://www.domain.com/find.html?destination=italy&price=500">show on page B</a><br> Page B contains: Code: <script type="text/javascript"> <!-- function loadIframe(){ if (location.search.length > 0){ url = unescape(location.search.substring(1)) window.frames["iframe"].location=url } } onload=loadIframe //--> </script> <iframe src="" name="iframe" id="iframe"</iframe> In this case page B will properly load requested link in iframe. Problem is it is just a static link... I want to display search result from the form. Thanks a lot for your help... Hi.. I have form and i want to input data using barcode and it will display on textbox and after input on the first textbox the focus will go to next textbox untill it will go on the last textbox and on the last textbox it will automatically save the data's on the database. How is it possible? here is my sample code: Code: <?php error_reporting(0); date_default_timezone_set("Asia/Singapore"); //set the time zone $con = mysql_connect('localhost', 'root',''); if (!$con) { echo 'failed'; die(); } mysql_select_db("mes", $con); ?> <html> <head> <script type="text/javascript"> function ini() { // Retrieve the code var code =document.getElementById ("code_read_box1").value; var code =document.getElementById ("code_read_box2").value; var code =document.getElementById ("code_read_box3").value; var code =document.getElementById ("code_read_box4").value; var code =document.getElementById ("code_read_box5").value; var code =document.getElementById ("code_read_box6").value; // Return false to prevent the form to submit return false; } </script> </head> <body onLoad="document.barcode.code_read_box1.focus()"> <form name=barcode onsubmit = "return ini()"> <input type="text" id="code_read_box1" value="" /><br/> <input type="text" id="code_read_box2" value="" /><br/> <input type="text" id="code_read_box3" value="" /><br/> <input type="text" id="code_read_box4" value="" /><br/> <input type="text" id="code_read_box5" value="" /><br/> <input type="text" id="code_read_box6" value="" /><br/> </form> </body> </html> Hello. I've been teaching myself HTML and CSS for a while, and now I've moved into the world of Javascript (but I'm still very much a beginner). For practice, I've been building a sample sign up form for a mock website, and I'm having problems with the birthdate section. The idea I had was to have MM, DD, and YYYY be the default values of my 3 textboxes (as an example for users), then set the value to nothing when the box gained focus. That all works fine, but I ran into problems when I tried to write an if statement to set the value back to MM, DD, or YYYY if the value was still nothing when the user clicked away. As it is now it just replaces the text inputted into the textbox (which of course is not good). Any ideas for what the problem might be? Code: <form name="signup" action="javascript:void(0);" method="post"> <table> <tr> <td>Date Of Birth:</td> <td> <input name="DOBmonth" type="text" value="MM" size="2" style="color: #555555;" onFocus="clearDOBmonth()" onBlur="restoreDOBmonth()" /> <input name="DOBday" type="text" value="DD" size="2" style="color: #555555;" onFocus="clearDOBday()" /> <input name="DOByear" type="text" value="YYYY" size="4" style="color: #555555;" onFocus="clearDOByear()" /></td> </tr> <tr> <td></td> <td><button name="Submit" type="submit" style="font-size: 1em;">Sign Up</button></td> </tr> </table> </form> <script type="text/javascript" language="javascript"> <!-- document.signup.DOBmonth.value="MM"; document.signup.DOBday.value="DD"; document.signup.DOByear.value="YYYY"; function clearDOBmonth() { document.signup.DOBmonth.value="";} function clearDOBday() { document.signup.DOBday.value="";} function clearDOByear() { document.signup.DOByear.value="";} function restoreDOBmonth() { if ('document.signup.DOBmonth.value = ""') { document.signup.DOBmonth.value = "MM"; // alert(document.signup.DOBmonth.value); } } //--> </script> Another side question, if I set a variable equal to the value of a textbox, then change the value of the variable, does that also change the value of the textbox? or is the variable no longer associated with the textbox. Example: Code: var a = document.form.textbox.value; a = blue; does document.form.textbox.value = blue? or is var a now completely independent of the textbox value? Thanks! Hi, i got a textbox with a submit button but when submit button is clicked it works but it reloads the page. is possible to submit without reload the page? thanks Hi, I have a text-box where you enter the phone nos. On key-press, i have written a validation code to enter only nos and "-". I have disabled Ctrl+v, but my customer want to enable ctrl+v for that text-box only. My requirement is after pasting the value it should automatically check for validation.. How to do it? Thanks... hi, I am tring to display some texts in a textbox using \n to create a new line but it does not work. PHP Code: <script> document.getElementById("txtbox1").value=" this is my firstline \n This is my second line \n this is my third line" </script> <input type="text" id="txtbox1"> thanks Hello How am I able to add a a cross to the right of a textbox which once click it clears the text from the textbox, sort of like the way Google do it, I have been trying to do this for ages now and can't seem to find a way to do it. Any help welcome, thank you. - DJCMBear Hi, I am having a very difficult time trying to get my text box to validate. I successfully validated my first program using prompts but now when I am using a HTML form I cannot get it to work. I have spent hours upon hours trying to get this working, any help would be greatly appreciated. Code: <html> <head> <title></title> <script type="text/javascript"> function validateform() { var temp = document.forms["inputform"]["temperature"].value while ((isNaN(temp)) || (temp == "")) { alert("Please enter a number"); return false; } if (parseFloat(temp) > 35) { alert("Wow, it's really hot!"); } else if (parseFloat(temp) <= 35) && (parseFloat(temp) >= 18)) { alert("It's a comfortable temperature right now"); } else if (parseFloat(temp) < 18) { alert("Brrr, it's a little bit cold for my liking"); } else { alert("Goodbye, and thanks for using TempReader"); } } </script> </head> <body> <form name="inputform" method="post" action=""> <table> <tr><td>What Is The Temperature?</td><td><input type="text" name="temperature"></td></tr> <!-- Below is submit button that when pressed validates the form --> <tr><td></td><td><input type="submit" value="Submit Details" onclick = validateform()></td></tr> </table> </form> </body> </html> Is it easy to add a smiley script to a guestbook ? I want a few faces like the ones on this page.. I hope there is some simple way to do this - google didnt really help me.. Its something like this im after : Visitor click on a smiley and following text goes to the textbook <img src="http://domain/images/smiley.gif" Thanks in advance... |