?
Solved

Why did JS on stop working?

Posted on 2014-03-21
6
Medium Priority
?
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 2000 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 53

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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

771 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