473,382 Members | 1,386 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,382 software developers and data experts.

JS - Object expected Error...please help

2
hi,

I am going mad........because of this error.....
I have done a simple coding........i am getting this error....
solution may be very simple,,,but i dont know..........can any body help me........

I am writing a function for onchange event in a drop down box, this is saying error.

html code:
[HTML] <tr>
<td>Number Of Bedrooms</td>
<td><select name=bedroom onchange="PopulateTextBox(this);">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
<option value=5>5</option>
</select>
</tr>
[/HTML]

Javascript code

Expand|Select|Wrap|Line Numbers
  1. <SCRIPT LANGUAGE="JavaScript">
  2.  
  3. function IsNumeric(strString)
  4.    //  check for valid numeric strings    
  5.    {
  6.    var strValidChars = "0123456789";
  7.    var strChar;
  8.    var blnResult = true;
  9.  
  10.    if (strString.length == 0) return false;
  11.  
  12.    //  test strString consists of valid characters listed above
  13.    for (i = 0; i < strString.length && blnResult == true; i++)
  14.       {
  15.       strChar = strString.charAt(i);
  16.       if (strValidChars.indexOf(strChar) == -1)
  17.          {
  18.          blnResult = false;
  19.          }
  20.       }
  21.    return blnResult;
  22.    }
  23.  
  24. function validate()
  25. {
  26. var str = document.propertyadd.reference_no.value;
  27. var return_val = IsNumeric(str)
  28. if(return_val == false)
  29.     {
  30.         alert("Reference No. not a numeric");
  31.     return false;
  32.     }
  33. else
  34.     {
  35.     return;
  36.     }    
  37. }
  38. function PopulateTextBox(get_obj)
  39. {
  40.     //int get_obj = document.proprtyadd.bedroom_no.value;
  41.     alert(get_obj);
  42.     for (int i=get_obj;i>0;i-- )
  43.     {
  44.         document.write("<tr><td>check here </td></tr>");
  45.  
  46.     }
  47. }
  48.  
  49. </SCRIPT>
any one please help ASAP....................
Feb 9 '07 #1
6 2161
acoder
16,027 Expert Mod 8TB
In your PopulateTextBox function, use get_obj.value:
Expand|Select|Wrap|Line Numbers
  1. function PopulateTextBox(get_obj)
  2. {
  3.     int objval = get_obj.value;
  4.     alert(objval); // just a test - remove later
  5.     for (int i=objval;i>0;i-- )
  6.     {
  7.         document.write("<tr><td>check here </td></tr>");    
  8.     }
  9. }
Just one thing: you're writing these rows to the screen, but there's no end table tag. That's another problem as is your isNumeric function, but let's deal with this one by one. Does this solve your problem?
Feb 9 '07 #2
dorinbogdan
839 Expert 512MB
I know that JavaScript has not the "int" data type.
It will work if replace:
- "int" by "var" , and
- "alert(get_obj)" by "alert(get_obj.value)"
Feb 9 '07 #3
dorinbogdan
839 Expert 512MB
Also , use:
Expand|Select|Wrap|Line Numbers
  1. for (var i=get_obj.value;i>0;i-- )
inside of PopulateTextBox function.
Feb 9 '07 #4
acoder
16,027 Expert Mod 8TB
Thanks, dorinbogdan, for that. When I posted the modified code, I didn't spot those errors. That should solve the errors for the OP.
Feb 9 '07 #5
juvin
2
hi,
Thanks for all of your help. The problem was "int"...I changed it and it worked.....Thanks Guys.....


Thanks a lot!!!!!!!!!!!!
Feb 10 '07 #6
acoder
16,027 Expert Mod 8TB
You're welcome. Glad you got your problem solved.
Feb 10 '07 #7

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

Similar topics

4
by: Bill | last post by:
I call a function in my .js file like this: onClick="location.href='blank.html' + generateSearchStringFromForm('section')" where section is the name of my form. The function is defined as...
1
by: TAM | last post by:
Hi, I have a simple JavaScript code that ensures that all the form fields are filled and there is also a function that checks if the email is a valid address. For some reason IE is giving...
2
by: Chuck Martin | last post by:
I am having a most frustrating problem that references, web searches, and other resources are no help so far in solving. Basically, I'm trying to design a pop-up window to be called with a funciton...
2
by: Ben | last post by:
I have several pages written in aspx, but sometime the aspx page return the following error. And it hapeen, the whole web application gives this error, that means all the aspx files get affected....
4
by: Kiyomi | last post by:
Hello, I am trying to replace my alert message box with a popup page. In my page behind,
26
by: yb | last post by:
Hi, Is there a standard for the global 'window' object in browsers? For example, it supports methods such as setInterval and clearInterval, and several others. I know that w3c standardized...
8
by: ipy2006 | last post by:
In my HTML I have, <input type="button" class="cartonsumkey" value="Sum Cartons" onclick="sumup(this);" /> In an external file that is called in Head area, I have, function sumup( o ) { ...
5
by: mackenzie | last post by:
Hello, I am looking for a little bit of help. I am trying to create a dynamically allocated object which contains one or more objects of type boost::pool<>. I get a compiler error when an object...
5
by: Ami | last post by:
Hi All, I am trying to create a class whose constructor takes Void parameter and stores it for future reference. It works fine as expected. class base { public: base(LPVOID pObj){ //store...
2
by: thj | last post by:
Hi. I've got this form that I'm trying to validate: <form id="periodForm" action="" method="post"> <p> Periode: <input id="startDate" name="startDate" type="text" size="7" value="<%=...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?

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.