473,721 Members | 2,062 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

If statement to long for one line, goes to next line

200 New Member
Good day, i have an If statement that is to long for one line goes to the second line.

I cant defein var for it as when the object are not there it gives an error.

So i had to go with the object value, I cant break it up more as it is a group of OR statements

How do i let the if continue on next line? please help

Expand|Select|Wrap|Line Numbers
  1.  else if((document.getElementById('VE1020User').value=="LOCAL" || document.getElementById('VE1020User').value=="NATIONAL") && document.getElementById('VE1060NewSupplier').value=="Yes" && document.getElementById('VE10IntVendorFields').value=="True")
  2.  {
  3.    if (document.getElementById('VE1080Name').value=="" || document.getElementById('VE10435SuppName').value=="" || document.getElementById('VE1090Postal').value=="" || document.getElementById('VE10445PostalCode').value=="" || document.getElementById('VE1010Province').value=="" || document.getElementById('VE10110Country').value=="" || document.getElementById('VE10120Phone').value=="" || document.getElementById('VE10130Fax').value=="" || document.getElementById('VE10140Email').value=="" || document.getElementById('VE10160Company').value=="" || document.getElementById('VE10170VendorType').value=="" || document.getElementById('VE10180Currency').value=="" || document.getElementById('VE10190Terms').value=="" || document.getElementById('VE10200PaymentType').value=="" || document.getElementById('VE10210Bank').value=="" || document.getElementById('VE10220BankCode').value=="" || document.getElementById('VE10230BankAccNo').value=="" || document.getElementById('VE10280SupplierAdd').value=="" || document.getElementById('V10290PhoneNumber').value=="" || document.getElementById('VE10310FaxNumber').value=="" || document.getElementById('VE10665TaxCode').value=="")
  4.  {
  5.  
Jan 20 '10 #1
6 17890
larztheloser
86 New Member
What do you mean "too long for one line"? There is no max. limit on how long a line can be. Likely that your text editor, or whatever you're using, is simply "wrapping" the IF line when it gets too long - but your code should still work normally. You can use an unlimited number of OR statements.

If you want, open your file in notepad (or whatever your os has) and that should display your IF statement without the new line. If it doesn't, delete the new line. Just to reiterate - lines can be as long as you like them. I'm sure I've written longer lines of javascript! (-;
Jan 20 '10 #2
ismailc
200 New Member
Hi, Thank You for the assisting.
I was opening it notepad (js file) but to check if was correct i double click the js file & it would complain about the If line
because it breaks oof to the next line.

I done this to get me going for the time being:
Expand|Select|Wrap|Line Numbers
  1.  else if((document.getElementById('VE1020User').value=="LOCAL" || document.getElementById('VE1020User').value=="NATIONAL") && document.getElementById('VE1060NewSupplier').value=="Yes" && document.getElementById('VE10IntVendorFields').value=="True")
  2.  {
  3.       VE1080Name = document.getElementById('VE1080Name').value;
  4.       VE10435SuppName = document.getElementById('VE10435SuppName').value;
  5.       VE1090Postal=document.getElementById('VE1090Postal').value;
  6.       VE10445PostalCode=document.getElementById('VE10445PostalCode').value;
  7.       VE1010Province=document.getElementById('VE1010Province').value;
  8.       VE10110Country=document.getElementById('VE10110Country').value;
  9.       VE10120Phone=document.getElementById('VE10120Phone').value;
  10.       VE10130Fax=document.getElementById('VE10130Fax').value;
  11.       VE10140Email=document.getElementById('VE10140Email').value;
  12.       VE10160Company=document.getElementById('VE10160Company').value;
  13.       VE10170VendorType=document.getElementById('VE10170VendorType').value;
  14.       VE10180Currency=document.getElementById('VE10180Currency').value;
  15.       VE10190Terms=document.getElementById('VE10190Terms').value;
  16.       VE10200PaymentType=document.getElementById('VE10200PaymentType').value;
  17.       VE10210Bank=document.getElementById('VE10210Bank').value;
  18.       VE10220BankCode=document.getElementById('VE10220BankCode').value;
  19.       VE10230BankAccNo=document.getElementById('VE10230BankAccNo').value;
  20.       VE10280SupplierAdd=document.getElementById('VE10280SupplierAdd').value;
  21.       V10290PhoneNumber=document.getElementById('V10290PhoneNumber').value;
  22.       VE10310FaxNumber=document.getElementById('VE10310FaxNumber').value;
  23.       VE10665TaxCode=document.getElementById('VE10665TaxCode').value;
  24.  
  25.       if (VE1080Name==""  || VE10435SuppName=="" || VE1090Postal=="" || VE10445PostalCode=="" || VE1010Province==""|| VE10110Country=="" || VE10120Phone=="" || VE10130Fax=="" || VE10140Email=="" || VE10160Company=="" || VE10170VendorType=="" || VE10180Currency=="" || VE10190Terms=="" || VE10200PaymentType=="" || VE10210Bank=="" || VE10220BankCode=="" || VE10230BankAccNo=="" || VE10280SupplierAdd=="" || V10290PhoneNumber=="" || VE10310FaxNumber=="" || VE10665TaxCode=="")
  26.       {
  27.          showDialog('Warning','All Information is required (INTERNAL - Vendor Application Form).','warning');                    
  28.       }       
  29.  
  30.  
Jan 20 '10 #3
larztheloser
86 New Member
What exactly was the error you were getting? A "line is too long" error, surely not!?
Jan 20 '10 #4
ismailc
200 New Member
The if would break to next line

If ... test
="" || test2="")

Error: At line: 50
Expected ")"

Regards
Jan 20 '10 #5
gits
5,390 Recognized Expert Moderator Expert
after having a look at the code first i would suggest to write a short helper method to shorten the code:
Expand|Select|Wrap|Line Numbers
  1. var getElVal = function(id) {
  2.     return document.getElementById(id).value;
  3. }
so you might use it like (and don't need to retype document.getEle mentById().valu e that much):
Expand|Select|Wrap|Line Numbers
  1. if ( (getElVal('VE1020User') == "LOCAL" 
  2.     || getElVal('VE1020User') == "NATIONAL") 
  3.     && getElVal('VE1060NewSupplier') == "Yes" 
  4.     && getElVal('VE10IntVendorFields') == "True" ) {
  5.  
  6.     // do something here
  7. }
basicly a condition don't need to be one line ... it is opened and terminated with corresponding brackets, so you could simply linebreak it. for readabilty it is best to have the conditions well seperated per line.

kind regards
Jan 20 '10 #6
ismailc
200 New Member
Silly me - Thank You works great
Expand|Select|Wrap|Line Numbers
  1.  else if((document.getElementById('VE1020User').value=="LOCAL" || document.getElementById('VE1020User').value=="NATIONAL") && document.getElementById('VE1060NewSupplier').value=="Yes" && document.getElementById('VE10IntVendorFields').value=="True"
  2.           && document.getElementById('VE1080Name').value==""  || document.getElementById('VE10435SuppName').value=="" || document.getElementById('VE1090Postal').value=="" 
  3.           || document.getElementById('VE10445PostalCode').value=="" || document.getElementById('VE1010Province').value=="" || document.getElementById('VE10110Country').value=="" 
  4.           || document.getElementById('VE10120Phone').value=="" || document.getElementById('VE10130Fax').value=="" || document.getElementById('VE10140Email').value=="" 
  5.           || document.getElementById('VE10160Company').value=="" || document.getElementById('VE10170VendorType').value=="" || document.getElementById('VE10180Currency').value=="" 
  6.           || document.getElementById('VE10190Terms').value=="" || document.getElementById('VE10200PaymentType').value=="" || document.getElementById('VE10210Bank').value==""
  7.           || document.getElementById('VE10220BankCode').value=="" || document.getElementById('VE10230BankAccNo').value=="" || document.getElementById('VE10280SupplierAdd').value=="" 
  8.           || document.getElementById('V10290PhoneNumber').value=="" || document.getElementById('VE10310FaxNumber').value=="" || document.getElementById('VE10665TaxCode').value=="")
  9.  {
  10.        showDialog();                    
  11.  } 
  12.  
Jan 20 '10 #7

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

Similar topics

4
2838
by: Benjamin | last post by:
Hello, I need some advice on a financial application I'm doing. First, I suppose I should give a little background so you know where I'm coming from. For 5 years I earned my living doing COBOL programming with some occasional VB and web programming with ASP. Prior to that I went to a technical college where I took a couple of courses in c, c++ and pascal. Although now about all I can do is the basic "hello world" type applications in...
4
2950
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400, like DOS, uses memory-mapped display, two bytes per character (one char byte and one attribute byte). We can get the screen offset allright, and I've written a javascript which does the math to convert the offset into row/col (i.e. left, top)...
11
50356
by: Colleyville Alan | last post by:
I posted that I was having trouble with a SQL statement that was working in the SQL window, but not in VBA. I have since discovered that when I create the string in VBA it is over 1023 characters long. When I copy this string into the SQL window, it splits into two lines, one of 1023 and the remainder in the next. When I remove that break, the query runs just fine. Since Access tells me that a string can hold 10^16 (64k), it did not...
5
3504
by: WindAndWaves | last post by:
Hi Team The function below searches all the tables in a database. However, if subsearch = true then it searches all the objects listed in a recordset (which are all table names). I thought to be really clever and use : #if subsearch ... #else ..... #end if
3
2496
by: Johnny M | last post by:
using Access 2003 Pardon the subject line, but I don't have a better word for this strange behavior (or behavior I don't understand!!!) I have a class module named DepreciationFactor. One of the properties is a follows (irrelevant code omitted):
4
1319
by: Jon Cosby | last post by:
Someone see why this is? If GaussPrime returns true, the debugger doesn't reach the next line in Factor. It goes directly the next line in the Click event. If false, it goes to the next block until it finds a prime. Private Function Factor(ByVal g As CNum) As CNum ... If GaussPrime(g) Then ' No more factors index += 1 ' Never reaches this breaking point
37
2138
by: Anony | last post by:
Hi All, I'm trying to chunk a long string SourceString into lines of LineLength using this code: Dim sReturn As String = "" Dim iPos As Integer = 0 Do Until iPos >= SourceString.Length - LineLength sReturn += SourceString.Substring(iPos, LineLength) + vbCrLf iPos += LineLength
35
3607
by: Thierry Loiseau | last post by:
Hello all, and Happy end year 2005 ! Well, I would like to obtain a list of all JavaScript var statement, With "for...in" perharps ? That is bellow my recent test here, but the problem is to management theses :-((( I must to declare and use all variable with this scheme :
7
2577
by: magmike | last post by:
I currently have a button once clicked, invokes the following: If Address_Select = -1 Then Forms!ProspectForm!Address = End If However, there are 11 other fields in the subform that i'd like to be included. However, when I did this: If Address_Select = -1 Then
18
7971
by: dspfun | last post by:
Hi! The words "expression" and "statement" are often used in C99 and C- textbooks, however, I am not sure of the clear defintion of these words with respect to C. Can somebody provide a sharp defintion of "expression" and "statement"? What is the difference between an expression and a statement?
0
8736
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9373
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9081
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5992
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
4497
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4761
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3206
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
2590
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2143
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.