Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not over - string parsing....:-) 1

Status
Not open for further replies.

dreamclutch

Programmer
Oct 3, 2005
21
US
Trying to parse out a date, and then compare it with two integer values from an options menu to see whether or not those two days(integers) are valid (if they are it runs the rest of the html, if not user is alerted with two days that they are allowed to use form). I think the problem area may be with my compare statement (if((holder) == dayOne || dayTwo) but not sure.



var holder
var theMonth
orderDate = new Date(document.form1.year.value, document.form1.month.value, document.form1.day.value)
holder = orderDate.getDay()
holder = parseInt(holder)

//this is to put the date in ##/##/#### format
theMonth = document.form1.month.value
theMonth = parseInt(theMonth)
theMonth = theMonth + 1
buildDate = theMonth + "/" + document.form1.day.value + "/" + document.form1.year.value
document.form1.theShipDate.value = buildDate
//is the selected date == to the day the shipment can be made
//alert(form1.Branch.options[form1.Branch.selectedIndex].value)

//splice form options data into comma delimited line with two intergers
var dayMush = form1.Branch.options[form1.Branch.selectedIndex].value.split(",");
var dayOne = parseInt( dayMush[0] );
var dayTwo = parseInt( dayMush[1] );


//if holder is equal to dayOne Integer or day two integer continue with page
if((holder) == dayOne || dayTwo){


}

//if not, alert user with only 2 days allowed

else{
if (form1.Branch.options[form1.Branch.selectedIndex].value == "SelectOne") {
alert("Please select a branch.")
return false
}


//get day of the week for alert
switch (dayOne) {
/code
}

switch (dayTwo) {
//code
}


_________________________________

<form name="form1" method="post" action="shipUpdate.asp" onSubmit="return check_date()">

//some other form code

//option values below (4 and 5) are parsed from a two db fields


<select name="Branch">
<option value="SelectOne" selected>Select One</option>
<option value="4,5" label="101-9th Avenue">101-9th Avenue</option>
</option>

//date option menu, etc.
 
Code:
if((holder) == dayOne || dayTwo){


}

Without really diving into your posted code, I think this may be the problem.

If you are trying to compare holder to each of those values, then you should be writing it like this:
Code:
if (holder==dayOne || holder==dayTwo) {
.
.
.
}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top