Solved

Why did JS on stop working?

Posted on 2014-03-21
6
224 Views
Last Modified: 2014-03-22
Hi,
I have a simple form that needs to display additional fields if visitors select "yes". It worked fine but stopped working.

I don't recall making changes that would have impacted the form and need help.

Will update with link or send entire page if needed.

Thanks,

Sally
____________________________________

The JS functions:

<script type="text/javascript" >
// to display the return trip data if the return trip box is checked //
// DisplayReturn//
function DisplayReturn() {
	var selectreturn = document.getElementById("returntrip");
    if (selectreturn.value=='yes') {
        document.getElementById("returnride").style.display = 'block';
        document.getElementById("returndate").value = '';
        document.getElementById("returntime").value = '';
        document.getElementById("returndate").focus;
    } else {
        document.getElementById("returnride").style.display = 'none';
        document.getElementById("returndate").value = 'n/a';
        document.getElementById("returntime").value = 'n/a';
    }

// get name of Adult at destination for after school //
// DisplayAdultName//
function DisplayAdultName() {
	var selectcp = document.getElementById("AdultAtDestination");
    if (selectcp.value=='yes') {
        document.getElementById("adultnamediv").style.display = 'block';
        document.getElementById("adultname").value = '';
        document.getElementById("adultname").focus;
    } else {
        document.getElementById("adultnamediv").style.display = 'none';
        document.getElementById("adultname").value = 'n/a';
    }
} 

</script>


My form elements:
					<p ><label for="returntrip">Is return car service needed?</label>
					<select name="returntrip" id="returntrip" onchange="javascript:DisplayReturn()" >
						<option value="no">choose</option>
						<option value="yes">yes</option>
						<option value="no">no</option>
					</select> </p>
					<div id="returnride" >
						<p ><label for="returndate">Return Flight Arrival Date</label>
						<input type="text" name="returndate" id="returndate" class="REQUIRED LENGTH_INPUT DATE medium" value="n/a"  placeholder="" />
						</p>
						<p ><label for="returntime">Return Flight Arrival Time</label>
						<input type="text" name="returntime" id="returntime" class="REQUIRED LENGTH_INPUT medium" value="n/a"  placeholder="" />
						</p>
						<p ><label for="returnairline">Return Airline</label>
						<input type="text" name="returnairline" id="returnairline" class="medium"  />
						</p>
						<p ><label for="returnflightno">Return Flight number</label>
						<input type="text" name="returnflightno" id="returnflightno" class="medium"  placeholder="" />
						</p>
						<p ><label for="cellphone">Cell Phone</label>
						<input type="text" name="cellphone" id="cellphone" class="medium"  placeholder="" />
						</p>
					</div>

Open in new window

0
Comment
Question by:sallywizard
  • 2
  • 2
6 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39946832
You're missing a '}' after the first function.
<script type="text/javascript" >
// to display the return trip data if the return trip box is checked //
// DisplayReturn//
function DisplayReturn() {
      var selectreturn = document.getElementById("returntrip");
    if (selectreturn.value=='yes') {
        document.getElementById("returnride").style.display = 'block';
        document.getElementById("returndate").value = '';
        document.getElementById("returntime").value = '';
        document.getElementById("returndate").focus;
    } else {
        document.getElementById("returnride").style.display = 'none';
        document.getElementById("returndate").value = 'n/a';
        document.getElementById("returntime").value = 'n/a';
    }
}  // <<<<<<<<<<<<<<<--------------------------------
// get name of Adult at destination for after school //
// DisplayAdultName//
function DisplayAdultName() {
      var selectcp = document.getElementById("AdultAtDestination");
    if (selectcp.value=='yes') {
        document.getElementById("adultnamediv").style.display = 'block';
        document.getElementById("adultname").value = '';
        document.getElementById("adultname").focus;
    } else {
        document.getElementById("adultnamediv").style.display = 'none';
        document.getElementById("adultname").value = 'n/a';
    }
}

</script>

Open in new window

0
 

Author Closing Comment

by:sallywizard
ID: 39947600
Thank you! I looked and looked and just missed it. That did the job.
0
 

Author Comment

by:sallywizard
ID: 39947604
To padas - Thank you. Should I have attached the code in a text file? not sure how I missed the code box but after missing the end bracket... ~ Sally
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39947641
You're welcome, glad to help.
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39947652
>Should I have attached the code in a text file?

No, the best thing is to use the code box.  In the comment box you can see there is Bold, Italics, Underling, Bullet, Number, H2, Link, Quote, Code, Snippet, Image.

I think the snippet creates an attachment and the Code just embeds and that is what I did.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

937 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now