Solved

Why did JS on stop working?

Posted on 2014-03-21
6
233 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 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 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

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
This video teaches users how to migrate an existing Wordpress website to a new domain.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

691 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