473,799 Members | 2,950 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

not defined addInput?

769 Contributor
Hey Everyone,

Well i keep getting the error that addInput is not defined but i can not figure out what is wrong with it. It worked perfectly fine when i was using it to submit data. But now that i am trying to make it display previously entered data it says addInput is not defined. could really use an idea on whats wrong with it because i can't figure it out.

here is what i have

javascript
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function addInput(divName){
  3. var dynamic = document.getElementById('dynamicInput');
  4. var thevalue = document.getElementById('theValue');
  5. var count = (document.getElementById('theValue').value -1)+ 2;
  6. thevalue.value = count;
  7. var newdiv = document.createElement('div');
  8. var divIdName = 'dynamic'+count+'Input';
  9. newdiv.setAttribute('id',divIdName);
  10.  
  11. newdiv.innerHTML =
  12. "<table class='zpExpandedTable' id='modeltable'>" +
  13. "<th class='sectiontitletick' colspan='7'>Serial Information "+ count +" </th>" +
  14. "<tr>" +
  15. "<td id='paddingformultitop'>Model No:&nbsp;&nbsp;&nbsp;&nbsp;</td>" +
  16. "</td>" +
  17. "<td>" +
  18.  "<select name='modelno_" + count + "'>" +
  19.  "<option value=''>Make A Selection</option>" +
  20. "<cfoutput query='models'>" + 
  21. "<option value='#model#'<cfif #model# is #model_no#>selected</cfif>>#model#</option>" + 
  22. "</cfoutput>" + 
  23.  "</select>" +
  24.  "</td>" +
  25.  "<td>" +
  26. "&nbsp;&nbsp;&nbsp;&nbsp;Product Type:"  +
  27. "</td>" +
  28. "<td>" +
  29. "<select name='producttype_" + count + "'>" +
  30. "<option value='' selected>No Choice</option>" +
  31. "<cfoutput query='getProdType'>" + 
  32. "<option value='#pk_productType#'<cfif #pk_productType# is #product_type#>selected</cfif>>#pk_productType#</option>" + 
  33. "</cfoutput>" + 
  34. "</select>" +
  35. "</td>" +
  36. "<td class='red'>" +
  37. "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type Of Hardware Failure*:" +
  38. "</td>" +
  39. "<td>" +
  40. "<select name='hardwarefailure_" + count + "'>" +
  41. "<option value='' selected>Make A Selection</option>" +
  42. "<cfoutput query='getHardwareFail'>" +
  43. "<option value='#pk_hardwareFailure#'<cfif #pk_hardwareFailure# is #type_hardware_failure#>selected</cfif>>#pk_hardwareFailure#</option>" +
  44. "</cfoutput>" +
  45. "</select>" +
  46. "</td>" +
  47. "</tr>" +
  48. "<table>";
  49.  
  50. newdiv.innerHTML = newdiv.innerHTML +
  51. "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0'>" +
  52. "<tr>" +
  53. "<td>" +
  54. "<input type='button' class='removeticket' value='Remove Serial &quot;"+count +"&quot;' onclick=\"removeElement(\'"+divIdName+"\')\"></a>" +
  55. "</td>" +
  56. "</td>" +
  57. "</tr>" +
  58. "</table>";
  59.  document.getElementById(divName).appendChild(newdiv);
  60.  
  61.  
  62. function removeElement(divNum) {
  63.   var d = document.getElementById('dynamicInput');
  64.   var olddiv = document.getElementById(divNum);
  65.   d.removeChild(olddiv);
  66. }
  67. </script>

heres the form
Expand|Select|Wrap|Line Numbers
  1. <body onload="addInput('dynamic');">
  2. <form action="userformedit.cfm" id="userForm"  name="userForm" method="POST" enctype="multipart/form-data" onclick="multipleSelectOnSubmit();">
  3. <input type="hidden" value="0" id="theValue" />
  4.      <div id="dynamicInput">
  5.  
  6.      </div>
  7.      <input type="button" class="addticket" value="Add Serial" onClick="addInput('dynamicInput');" >
  8. <input type="submit" value="submit" name="submit">
  9. </form>
  10. </body>
Thank you in advance,
Rach
Sep 16 '08 #1
19 2570
rnd me
427 Recognized Expert Contributor
in line 59 you try to append the newly created div to another element, an element with the id "dynamic". i don't see this tag anywhere in your code.

you could change the reference, and hard code "dynamicInp ut" instead.

if the function itself is not working, but you are not seeing any errors upon boot, check the long string that build the new div's .innerHTML for breaks.

EDIT: ok, your string is fine, as is the function overall (well, fine: maybe, syntax-error-free: yes).

is the script block you posted in the document's head, or is it in an external file?
if it's in an external files, remove the actual script tag code at the start and end.
Sep 16 '08 #2
bonneylake
769 Contributor
in line 59 you try to append the newly created div to another element, an element with the id "dynamic". i don't see this tag anywhere in your code.

you could change the reference, and hard code "dynamicInp ut" instead.

if the function itself is not working, but you are not seeing any errors upon boot, check the long string that build the new div's .innerHTML for breaks.

EDIT: ok, your string is fine, as is the function overall (well, fine: maybe, syntax-error-free: yes).

is the script block you posted in the document's head, or is it in an external file?
if it's in an external files, remove the actual script tag code at the start and end.
Hey rnd me,

Thank you for your response. The script is in the documents head in my file. An this does work correctly with no errors if your are using it to insert information, but i am not trying to make it where i can edit previously entered information an now i am getting errors with it.

What i am trying to do is i used this to insert information and now i am trying to make it where i can use it to edit the information. The first problem i am running into is when i load the page nothing appears except the button to add more serial numbers. When i am inserting the information when the page loads the first serial number to fill out appears an then the button appears below to add more.Now that i am trying to display previously entered information nothing appears when the page loads except the button. If you click the button then it will show you the serial number you filled out, an it will continue to show you the same one every time you click add, i am only trying to show what was entered before and they also have to be able to add more serial numbers to it. But right now just trying to get it to display the serials filled out when the form appears but i have no clue how to go about this. I know that the errors come from the line you mentioned an its been having a trouble with the onload in the body tag.But if you have any suggestions to go about this i would very much appreciate it

Thank you for the help :),
Rach
Sep 17 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
If you want to call it onload, change the 'dynamic' to 'dynamicInput' when calling addInput().
Sep 18 '08 #4
bonneylake
769 Contributor
If you want to call it onload, change the 'dynamic' to 'dynamicInput' when calling addInput().
Hey Acoder,

Wow i did not realize that would be so easy an it totally makes sense to me now!
But i do got a few more questions on this if you don't mind answering them.
I was wondering if there was a way to display the previously entered information (when the page loads) an still allow the user to add more serial numbers an still allow them to remove them?
i been trying to figure out for days if this is possible/how i can do this but i have no clue where to begin.

Thank you,
Rach
Sep 18 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
Yes, you can. Keep a count to keep each ticket unique and use that to identify the div to remove.
Sep 18 '08 #6
bonneylake
769 Contributor
Yes, you can. Keep a count to keep each ticket unique and use that to identify the div to remove.
Hey Acoder,

i am a bit confused by what you mean. I figured i would have to keep the count . But what i am confused on is this.It has to be able to display multiple tickets that were filled in. An then if they decide to add another ticket they need to be able to click add ticket an nothing appears in any fields when they click on add ticket. Right now if i click add ticket it displays what was previously written. So i dont' know if i need to copy all the tables in the javascript an make those have the values to display what was previously written an then have another copy of the tables where it will display nothing in the fields. Just not sure how to go about this.

Thank you,
Rach
Sep 18 '08 #7
acoder
16,027 Recognized Expert Moderator MVP
Yes, I see what you mean now. Either use another function or reuse this one with the values as parameters rather than hard-coded values to make it more generic.
Sep 18 '08 #8
bonneylake
769 Contributor
Yes, I see what you mean now. Either use another function or reuse this one with the values as parameters rather than hard-coded values to make it more generic.
Hey Acoder,

how would i make the values as parameter?not really sure what the difference between parameters and hard-coded values is.

Thank you,
Rach
Sep 18 '08 #9
acoder
16,027 Recognized Expert Moderator MVP
A parameter/argument would be something you pass to the function in the brackets which you can use within the function. In your code, the Coldfusion code sets the selected values. What you could do have an argument that determines whether this is for displaying the first ticket or for adding new input. If you want to avoid all this, just create another similar function without Coldfusion setting the selected attribute for the options and call that for the add button.
Sep 18 '08 #10

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

Similar topics

3
4646
by: Dave | last post by:
Hello all, Please consider this code: #ifndef FOO_INCLUDED #define FOO_INCLUDED // File: foo.h class foo {
2
5486
by: David Emme | last post by:
Access 97 I have a number of SELECT statements which contain references to user-defined VBA functions. These typically work as expected, but occasionally, on one user's machine or another, produce a "function not defined" message when the SELECT statement is executed, even having previously worked on that machine. What can I do to correct this difficulty when it occurs? What do I need to know about user-defined functions in SELECT...
3
5082
by: Leiji Liu | last post by:
Hi, I am curious if there are any pre-defined varables (constants?) in C? I saw some code with __LINE__, __FILE__, etc. Are those located in some include files? LL
19
2588
by: E. Robert Tisdale | last post by:
In the context of the comp.lang.c newsgroup, the term "undefined behavior" actually refers to behavior not defined by the ANSI/ISO C 9 standard. Specifically, it is *not* true that "anything can happen" if your C code invokes "undefined behavior". Behavior not defined by the ANSI/ISO C 9 standard may be defined by some other standard (i.e. POSIX) or it may be defined by your compiler, your operating system or your machine architecture.
7
1666
by: William L. Bahn | last post by:
I'm working on some lessons and want to be sure I get some stuff correct. If any of this is covered in the FAQ, please feel free to point me to the section - I couldn't find it. ---------------------------------------------------------------- Overflow/Wraparound behavior of integer values ---------------------------------------------------------------- If an arithmetic operation such as (+, -, *) yields a result that exceeds the...
6
74357
by: Michael B Allen | last post by:
Which is the preferred method for preprocessor tests and why? #ifdef XYZ or #if XYZ or #if defined(XYZ) and
6
7614
by: karthi | last post by:
hi, I need user defined function that converts string to float in c. since the library function atof and strtod occupies large space in my processor memory I can't use it in my code. regards, Karthi
4
3313
by: Rui.Hu719 | last post by:
Hi, All: I read the following passage from a book: "There are three exceptions to the rule that headers should not contain definitions: classes, const objects whose value is known at compile time, and inline functions are all defined in headers. " Can someone explain to me why some of the const objects must be defined in the header file?
2
4247
by: curious2007 | last post by:
During the linking I get the following: 1>Linking... 1>main.obj : error LNK2005: "double __cdecl sigma(class curious2007::pair<double,double> const &)" (?sigma@@YANABV?$pair@NN@curious2007@@@Z) already defined in Characteristics.obj 1>main.obj : error LNK2005: "double __cdecl sigma_linear(struct std::pair<double,double> const &)" (?sigma_linear@@YANABU?$pair@NN@std@@@Z) already defined in Characteristics.obj 1>main.obj : error LNK2005:...
0
9686
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10222
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9068
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7564
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4139
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.