JavaScript - Subtracting From Health Variable Using Onclick Function?
Well, I'm a beginner to coding, so I need some help.
I'm trying to create a short, html/javascript mario text game. Now, in the beginning, he fights a goomba. He has a health and energy number as variables: Code: <p><img src="http://img253.imageshack.us/img253/9202/mariodisplayidlefront.png" align="middle" hspace=20> <font size=3 color="red"> Health: <script language= "javascript"> var mariohealth = '20'; document.write(mariohealth); </script> </font> <br><font size=3 color="green"> Energy: <script language= "javascript"> var marioenergy = '20'; document.write(marioenergy); </script> </align> </font> And the goomba has health: Code: <p><br><img src="http://img23.imageshack.us/img23/9438/goombafrontdisplay.png" align="middle" hspace=20> <font size=3 color="red"> Health: <script language= "javascript"> var goombahealth = '10'; document.write(goombahealth); </script> </font> And then, there will be different buttons for different attacks. However, the only one created is "Punch", with this code: <FORM> <INPUT type="button" value="Punch" name="Mario Punch" onClick="?"> </FORM> What would I put in the onClick function to make it subtract 4 health from the goomba and 2 health from Mario Similar TutorialsI'm currently working on a project and I am doing a bunch of image switching. I'm having a problem with the following... I have seven medium image objects and one small one. One is at the top and the other 7 are below. When one of the 7 is clicked, it then becomes the one up top and the one up top then takes the place of the image clicked. This needs to be able to happen no matter which of the seven i click. Also when you click one of the seven it runs a script to change 9 other images in the center of the page. this isnt too important because i have it working already. What i have is, each of the seven images run their function that changes the 9 center images and then it runs another function. What i need is for that function to determine which company for example(shaws, lowes, target) the top image belongs to and replace the image that was clicked with the top one. But i also need to replace the NAME="" and ONCLICK="function()" with the proper ones for the original company up top. Please if you can understand what im trying to do let me know, if you need further clarification i can do so. i can draw a picture of what im trying to do or the layout if needed but i cant necessarily show anyone the project due to a non-disclosure. I am trying to use an onclick statement to go to an alternate web page displaying a different version of tha file being displayed in the current page. In the HEAD section of the current page I have a global variable named currentfile that contains a file name. This function is also in the HEAD section immediately below the variable's declaration Code: function altlink() { gotolink = "http://www.mydomain.com/testpage.htm?alt=" + currentfile; return gotolink } I have tried every combination I can think of in the onclick code to get it to work but, no joy. here is an example: Code: <a href="#" onClick=altlink(); return false; <img src="change.png" width="47" height="30"></a> If anyone here can sort me out I'd really appreciate it. I just can't get the next page to load. i have an image with an onclick function and parameters 0,1 i want to change the parameters of the onclick function through the same function? Code: <img id="down0" onclick=swap(0,1) /> <javascript> function swap(a,b){ var imgda=document.getElementById('down'+a); imgda.onclick = swap(b,b+1); } </javascript> normally it should change the onclick to swap(1,2) but it remains 0,1 whats happening?? p.s. plz dont tell me about the javascript tag, its just for quick explaining... I'm doing a school project and I am using JPlayer as a media player. The site is essentially a music jukebox with a search. I have the playlist set up in the jukebox with 5 songs from the start, but I need to make it so that when you do a search and click the plus sign button next to a song, it will change one of the songs in the playlist to that song. I have the search and everything working but when I click the button it does not actually change the variable in the javascript. Any help or insight to this would be much appreciated. Below is the javascript (with some PHP, but that shouldn't effect what I need). Thanks in advance!! Code: <link rel="stylesheet" href="stylesheets/style.css" type="text/css" /> <!-- CSS files required for JPlayer --> <link type="text/css" href="skin/jplayer.blue.monday.css" rel="stylesheet" /> <link rel="stylesheet" href="skin/jplayeraudio.css" type="text/css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.jplayer.min.js"></script> <script type="text/javascript"> <!-- var nextSet = 1; <?php $songsInDB = 70; $rand1 = rand(1, $songsInDB); $rand2 = rand(1, $songsInDB); while($rand2 == $rand1) { $rand2 = rand(1, $songsInDB); } $rand3 = rand(1, $songsInDB); while($rand3 == $rand2 || $rand3 == $rand1) { $rand3 = rand(1, $songsInDB); } $rand4 = rand(1, $songsInDB); while($rand4 == $rand3 || $rand4 == $rand2 || $rand4 == $rand1) { $rand4 = rand(1, $songsInDB); } $rand5 = rand(1, $songsInDB); while($rand5 == $rand4 || $rand5 == $rand3 || $rand5 == $rand2 || $rand5 == $rand1) { $rand5 = rand(1, $songsInDB); } ?> var var1 = <?php echo $rand1; ?>; var var1artist = '<?php echo $database->getSongArtist($rand1); ?>'; var var1title = '<?php echo $database->getSongTitle($rand1); ?>'; var var2 = <?php echo $rand2; ?>; var var2artist = '<?php echo $database->getSongArtist($rand2); ?>'; var var2title = '<?php echo $database->getSongTitle($rand2); ?>'; var var3 = <?php echo $rand3; ?>; var var3artist = '<?php echo $database->getSongArtist($rand3); ?>'; var var3title = '<?php echo $database->getSongTitle($rand3); ?>'; var var4 = <?php echo $rand4; ?>; var var4artist = '<?php echo $database->getSongArtist($rand4); ?>'; var var4title = '<?php echo $database->getSongTitle($rand4); ?>'; var var5 = <?php echo $rand5; ?>; var var5artist = '<?php echo $database->getSongArtist($rand5); ?>'; var var5title = '<?php echo $database->getSongTitle($rand5); ?>'; var playItem = 0; $(document).ready(function(){ var myPlayList = [ {name:var1artist+" - "+var1title, mp3:"music/"+var1+".mp3"}, {name:var2artist+" - "+var2title, mp3:"music/"+var2+".mp3"}, {name:var3artist+" - "+var3title, mp3:"music/"+var3+".mp3"}, {name:var4artist+" - "+var4title, mp3:"music/"+var4+".mp3"}, {name:var5artist+" - "+var5title, mp3:"music/"+var5+".mp3"}, ]; // Local copy of jQuery selectors, for performance. var jpPlayTime = $("#jplayer_play_time"); var jpTotalTime = $("#jplayer_total_time"); $("#jquery_jplayer").jPlayer({ ready: function() { displayPlayList(); playListInit(false); // Parameter is a boolean for autoplay. }, ended: function() { playListNext(); }, swfPath:"/js", nativeSupport: true, supplied: "mp3" }); $("#jplayer_previous").click( function() { playListPrev(); $(this).blur(); return false; }); $("#jplayer_next").click( function() { playListNext(); $(this).blur(); return false; }); function displayPlayList() { $("#jplayer_playlist ul").empty(); for (i=0; i < myPlayList.length; i++) { var listItem = (i == myPlayList.length-1) ? "<li class='jplayer_playlist_item_last'>" : "<li>"; listItem += "<a href='#' id='jplayer_playlist_item_"+i+"' tabindex='1'>"+ myPlayList[i].name +"</a></li>"; $("#jplayer_playlist ul").append(listItem); $("#jplayer_playlist_item_"+i).data( "index", i ).click( function() { var index = $(this).data("index"); if (playItem != index) { playListChange( index ); } else { $("#jquery_jplayer").jPlayer("play"); } $(this).blur(); return false; }); } } function playListInit(autoplay) { if(autoplay) { playListChange( playItem ); } else { playListConfig( playItem ); } } function playListConfig( index ) { $("#jplayer_playlist_item_"+playItem).removeClass("jplayer_playlist_current").parent().removeClass("jplayer_playlist_current"); $("#jplayer_playlist_item_"+index).addClass("jplayer_playlist_current").parent().addClass("jplayer_playlist_current"); playItem = index; $("#jquery_jplayer").jPlayer("setMedia", myPlayList[playItem]); } function playListChange( index ) { playListConfig( index ); $("#jquery_jplayer").jPlayer("play"); } function playListNext() { var index = (playItem+1 < myPlayList.length) ? playItem+1 : 0; playListChange( index ); } function playListPrev() { var index = (playItem-1 >= 0) ? playItem-1 : myPlayList.length-1; playListChange( index ); } }); function loadSong(songID, artist, title) { if(nextSet == 1){ var1 = songID; var1artist = artist; var1title = title; nextSet++; } else if(nextSet == 2){ var2 = songID; var2artist = artist; var2title = title; nextSet++; } else if(nextSet == 3){ var3 = songID; var3artist = artist; var3title = title; nextSet++; } else if(nextSet == 4){ var4 = songID; var4artist = artist; var4title = title; nextSet++; } else if(nextSet == 5){ var5 = songID; var5artist = artist; var5title = title; nextSet++; } if(nextSet > 5){ nextSet = 1; } alert("Song has been queued! "+nextSet) } var i = 1; $(document).ready(function(){ $(".search").click(function(){ $.post("livequery.php", { keywords: $(".keywords").val(), mode: $(".mode").val() }, function(data){ $("table#content").empty() $.each(data, function(){ var _class = "search_content1"; if(i % 2 == 0) { _class = "search_content2"; } $("table#content").append("<tr class='"+_class+"'><td class='trunc_table' width='4%'><input type='button' value='+' onClick=\"loadSong('"+this.id+"', '"+this.artist+"', '"+this.title+"')\" /></td><td class='trunc_table' width='27%'>" + this.title + "</td><td class='trunc_table' width='1%'> </td><td class='trunc_table' width='22%'>" + this.artist + "</td><td class='trunc_table' width='1%'> </td><td class='trunc_table' width='16%'>" + this.album + "</td><td class='trunc_table' width='1%'> </td><td class='trunc_table' width='14%'>" + this.genre + "</td><td class='trunc_table' width='1%'> </td><td class='trunc_table' width='13%'>" + this.mood + "</td></tr>"); i++; }); }, "json"); }); }); --> </script> Also, the code for the playlist is in the myPlayList array, which I'm referencing the title, artist, and filename with the javascript values. I'm trying to change them in the function loadSong(songID, artist, title). I get the alert popup that I have in there, but no values change as far as the songs. So ill try best to describe what im doing, I grab information from a database and it displays with its model number and a value. I use that value to put into a URL so it will go to the database and delete that values entry. It works excpet it ALWAYS grabs the last value(aka the last entry). So i need it to grab what ive selected rather than the last value. Any help will be great! Code: <form name="addswitchtype" id="addswitchtype" action="<?php echo $this->url('system/switch_management/newtype'); ?>" method="POST"> <h4>Update Switch Model Information</h4> <table> <select name"switchtypeid" id="switchtypeid"> <option value="">New</option> <?php foreach($this->switchtype as $switch_type): ?> <option value"<?php echo $switch_type->switchtypeid; ?>"><?php echo $switch_type->switchmodel; ?></option> <?php endforeach; ?> </select> </table> <div id="switchtype-data" style="padding-top: 10px;"></div> <input type="submit" name="submit" value="Add Switch Type" /> <input type="button" value="Delete Switch" onclick="javascrip:document.location.href='<?php echo $this->url('system/switch_management/building/switch/' . $switch_type->switchtypeid . '/deletetype'); ?>'" /> <tr> </form> I have a form, that when the user click Submit, I need a php variable to be echoed to the page. This is for an upload page. So when they are waiting for the file to upload, it will say "Uploading..." until the upload is complete. All I know so far is I need to create a javascript function and include it in the submit button. This is all I have so far in the submit button tag: onClick="Transferring();" Now I need to figure out the code to include in this function. Any ideas? I'm trying to make a basic rss reader with a google reader-esque functionality of clicking on article names and being able to expand/collapse that article. I'm working on the expand part and am going crazy. I am having no trouble getting content and displaying it without the onclick function but when I try to integrate onclick I can just get the titles. here's the snippet. any help? Code: <!-- HTML --> <body> <div id="feeddiv"></div> <script type="text/javascript"> // feed stuff using Google Feed API function feedLoaded(result) { if (!result.error) { // Grab the container we will put the results into var container = document.getElementById('feeddiv'); container.innerHTML = ''; // Loop through the feeds, putting the titles onto the page. for (var i = 0; i < result.feed.entries.length; i++) { var entry = result.feed.entries[i]; var content = entry.content; var title = entry.title; var url = entry.link; var div = document.createElement('div'); //parentDiv for articles var articleTitle = document.createElement('div'); articleTitle.setAttribute('name', i); //set articleTitle name to article's place in array articleTitle.setAttribute('style', 'font-weight:bold;font-size:15px;'); articleTitle.innerText = title; articleTitle.onclick = function() {populate(content, title, url, i);}; div.appendChild(articleTitle); //adds title to div container.appendChild(div); //adds div to the container } } } function populate(content,title, url, i) { var article = document.getElementByName(i); //gets articleTitle //clickable title var a = document.createElement('a'); //creating title link var href = document.createElement('href'); a.setAttribute('href', url); //putting actual url into html a.setAttribute('style', 'font-size:25px;'); a.innerText = title;//still puts into html //Text var snippet = document.createElement('p'); //creates <p> to throw articles in snippet.innerHTML = content; //renders the article article.appendChild(a); article.appendChild(snippet); } </script> </body> Hello, I am trying to access a dynamic asp variable with onclick either in a javascript function where I can use it globally or set another div id with this dynamic variable. Any help is very much appreciated. Thank you! <script> function doSomething(article_id) } return article_id; } </script> <a href="#test" onClick="doSomething("<%=rsHeadline("article_id")%>")">try here...</a> <div id="test"> <%articleid = request.querystring("article_id") %> <% Response.Write articleid %> The article id is articleid</div> Below is the code that is using the name FFF in various places. The effect of all this is that the onclick function is not executed. I would expect a pop up alert when clicking the submit button. This only happens if I rename either the form id or the js variable. Can anyone explain what is going on here ? Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Title</title> </head> <script type="text/javascript"> function newobject(){ this.exec=exec; function exec(){ alert("exec"); } } FFF = new newobject(); </script> <body> <form id=" FFF " name="somename" action="" method="GET"> <input type="text" id="someid" name="somename" value="value"> <input onclick=" FFF .exec()" type="submit" id="submitid" name="somesubmit" value="xxx"> </form> </body> </html> Regards Heinz Simply put, I need to take a variable (The number '20' in this case) that is displayed by an input box on my web page and plug it into a function so that whenever I click on a button, the number in the input box will decrease by 1. Seems simple enough, though for hours I've been going at it with no luck. Skipping the rest of my code - I currently have: Code: <head> <title> Online Slots </title> <script type="text/javascript" src="http://dave-reed.com/book/random.js"> </script> <script type="text/javascript"> function DoSpin() { var count; count = 20 document.getElementById("countBox") = count - 1; } </script> </head> <body> <div style="text-align:center"> <input type="button" value="Click to Spin" onclick="DoSpin()" /> <br /><br /> Current Funds: <input type="text" id="countBox" size="4" value="20" onfocus="blur();" /> </div> </body> The entire code is a slot machine project that's supposed to be extremely simple where you hit the button and it spins 3 wheels, 3 of the same image and you win. Every spin takes $1, every win gives $13. The majority of the code is already working, however for some reason I appear to be failing badly at getting the read out to show a decrement of $1 every time you push the button. I know this is a bit newbie of a question to be asking; but I've tried so many different ideas that I've found across w3schools, webdevelopersnotes, dave-reed, ect - and so far I haven't been able to get any of them to work correctly. Any help would be great! I have a html page with a lot of thumbnails. The idea is that when the user clicks on an image the onClick event is to display another detailed form and deliver to that form the name of the image in a variable. In the detailed php-form there is a query to MySQL to retrieve a record. The record will be retrieved by a Query based on the name of the picture. Apparently the PHP cannot do the job. I had an idea to make the thumbnail page as a form and to use use a hidden field with the thummnail name which should be carried on with the $_POST array through the submit button but i do not want to have a submit button. The more elegant way is just by clicking the picture the detailed page is opened and the variable is transferred where my php code can make use of the variable for the query. I have never used java before so you have to excuse for the lack of knowledge. Can anyone gie me an idea how i should implemnt this Best regards MSP Hey all, I'm using a fairly simple accordion script. When I went to take a gander at the page in IE I found that the onclick function of the script doesn't respond. It works in FF, Safari, Chrome and Compatibility Mode in IE 8 the error message IE gives me is Quote: Message: 'h' is null or not an object Line: 13 Char: 77 Code: 0 URI: http://proposalfor.us/js/script.js The problem line (as far as I can tell) is: Code: this.a[s]={}; this.a[s].h=h=T$$(e,v)[0]; this.a[s].c=c=T$$('div',v)[0]; h.onclick=new Function(this.n+'.pr(0,'+s+')'); Any help would be greatly appreciated! Thanks friends! I have a html page with a lot of thumbnails. The idea is that when the user clicks on an image the onClick event is to display another detailed form and deliver to that form the name of the image in a variable. In the detailed php-form there is a query to MySQL to retrieve a record. The record will be retrieved by a Query based on the name of the picture. Apparently the PHP cannot do the job. I had an idea to make the thumbnail page as a form and to use use a hidden field with the thummnail name which should be carried on with the $_POST array through the submit button but i do not want to have a submit button. The more elegant way is just by clicking the picture the detailed page is opened and the variable is transferred where my php code can make use of the variable for the query. I have never used java before so you have to excuse for the lack of knowledge. Can anyone gie me an idea how i should implemnt this Best regards MSP I don't know how I should do ? Quote: <html> <head> <script type="text/javascript"> function add(a,b){ y=a+b return y } var aaa = add(one,two) //one needs to get somehow get the value of yil, in this case 10 var one = function reas(){i=10;if(i<10){yil = 15}; else{yil = 10; yil = one;}; var two = 20; document.write(y) </script> </head> </html> also why doesn't this work? Quote: <html> <head> <script type="text/javascript"> function adder(a,b){ var k=a+b; return k } var hes=adder(5,kol); kol=40; alert(hes); </script> </head> </html> you cannot have variables in callback functions? I guess it is because it is 2am and had a few beers but i cannot get this to work and i know its pretty simple to do - see the code below: Code: {if ""|fn_needs_image_verification == true} {assign var="is" value="Image_verification"|fn_get_settings} <p{if $align} class="{$align}"{/if}>{$lang.image_verification_body}</p> {assign var="id_uniqid" value=$id|uniqid} {literal} <script language="javascript" type="text/javascript"> function reloadCaptcha() { captcha = document.getElementById("captureURLID").src; return captcha += 'reload'; } </script> {/literal} {if $sidebox} <p><img id="verification_image_{$id}" class="image-captcha valign" src="{"image.captcha?verification_id=`$SESS_ID`:`$id`&`$id_uniqid`&"|fn_url:'C':'rel':'&'}" alt="" onclick="this.src += 'reload' ;" width="{$is.width}" height="{$is.height}" /></p> {/if} <p><input class="captcha-input-text valign" type="text" name="verification_answer" value= "" autocomplete="off" /> {if !$sidebox} <img id="verification_image_{$id} captureURLID" class="image-captcha valign" src="{"image.captcha?verification_id=`$SESS_ID`:`$id`&`$id_uniqid`&"|fn_url:'C':'rel':'&'}" alt="" onclick="this.src += 'reload' ;" width="{$is.width}" height="{$is.height}" /> {/if} <img src="{$images_dir}/icons/icon_reload.png" height="25" width="25" alt="Reload Captcha Image" onclick="reloadCaptcha();" class="valign image-captcha" /></p> {/if} now the following works totally fine, when you click the captcha code changes..... "onclick="this.src += 'reload'" you will notice i have added a custom reload button image below this with a onclick calling a custom function "reloadCaptcha(); which i want to reload the captcha image above it - however it is not working, i have done the function so it grabs the src from the element ID, i have added 2 ID's to the IMG but cannot remember if you can have multiple IDs or not which if not could be causing the problem but not 100% sure how to include the smarty code for the generated ID on that image. Any ideas on the code above from having a quick glimps? as the code stands i get the error: Error: captureURL is null Many Thanks I'm having a small issue with being able to use the onclick more than once. When I load the page and click the link the request works fine the first time. But if I cancel the request then goto click the link again, nothing happens. Code: <a href="javascript:void();" onclick="sendRequest()">Send the request</a> <script> var request = { method: 'postrequest', message: 'You will like it', data: '123key' }; function sendRequest() { postReq(request, function (a) { if (a && a.post_id) { //Do something if sent } else { //Do something if cancelled } }) } </script> I have an external js file which contains the function which for now opens an alert box. The div on the page should run the function when it is clicked but it isn't. I have tried changing the function to an alert to check the click event is working and i have tried running the javascript in the address bar Code: javascript:hasFocus(); to ensure it has loaded correctly. Both are working fine and i am getting no errors. Below is a snippet of the code: Code: function hasFocus() { alert("a"); } Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" language="javascript" src="scripts/cms.js"></script> </head> <body> <div id="tab_panel"> <div id="tabs"></div> <div id="content" contenteditable="true" onclick="hasFocus();"></div> </div> </body> </html> Thanks in advance Hi guys. I have made a PHP script that queries a database and uses the reponse to display multiple radio boxes (using a while loop). What I would like to do is have the page URI updated when a radiobox is clicked, without the user having to press on a "Submit" button or something. This is where Javascript comes into play. As this is a while loop, there is no specific number of responses or prefixed names. I've found a lot of stuff on Google with functions calling ID's, and then if the ID matches do a predefined response. Of course that wouldn't work in this situation, and to be frank I don't need anything near as complex. What I'm looking to do is call a Javascript function to redirect the page to "...?location=<get location from PHP var>&id=<get ID from checkbox ID/name>". When the page reloads, I can then use the PHP $_GET["id"] function to display data. It sounds SO simple in theory! Can anyone help? What i've done (and failed): Code: echo "<form>"; while ($explode_count_dec > "0"): $while_query = mysql_query("SELECT * FROM printers WHERE ID LIKE '$explodedata[$explode_number]'"); $while_result = mysql_fetch_assoc($while_query); echo "<input type='radio' value='".$explodedata[$explode_number]."' name='printer' onClick='showmore(".$explode_number.")' />".$while_result["Model"]." <BR /> "; ++$explode_number; --$explode_count_dec; endwhile; echo "</form>"; and the JS: Code: <script type="text/javascript"> function showmore($text) { var room = "<?= $get_location; ?>"; window.location = "?location=" + room + "&id=" + <?php $text; ?> // Couldn't do just $text here? I wish I knew JS.. } </script> I am creating a weather widget for the iphone. The program creates an xml request for a weather feed and then parses the response. Depending on the response different information is displayed. A different icon for each weather pattern. I have all of this working so far. What I want to integrate is the option to refresh the weather when a user taps on the icon. Here is my code: Code: document.getElementByID("weatherIcon").innerHTML="<img src=\"Icon Sets/"+iconSet+"/"+MiniIcons[obj.icon]+iconExt/" border=2 onclick=\"refresh();\">" Code: function refresh() { weatherRefresherTemp(); } I know that the function refresh works because it is called from another function that allows the refresh to happen automatically every 30 min. However, wanting to integrate an option to manually refresh I am trying to do it this way. The code never seems to fire, nothing happens. I've added the border option for testing and don't even see that. I've been using a javascript editor and I do not get any errors. Any suggestions would be greatly apprectiated. Hello and thanks for letting me on this forum! Im pretty new to JScript and I am still getting used to it all. I am trying to make a Website that allows values to be selected from one form, transferred to the next form as a summary and then completed. The values are sent to the page fine but my Validation is broken. Here is my LINK code In the Form Code: <form id="Tickets" onsubmit="return ValidateForm()" action="Details.html"> And in the Submit Button Code: <input type="submit" id="OrderTickets" value="Order Tickets" onclick="return ValidateForm()" > My validation is as follows Code: <script type = "text/javascript"> function ValidateForm() { if( document.getElementById('DepartingStation').selectedIndex == " ") { alert( "Please provide a Departing Station!" ); document.getElementById('DepartingStation').focus() ; return false; } if( document.getElementById('ArrivingStation').selectedIndex == " ") { alert( "Please provide an Arriving Station!" ); document.getElementById('ArrivingStation').focus() ; return false; } var Depart = document.getElementById('DepartingStation').value; var Arriv = document.getElementById('ArrivingStation').value; if( Depart==Arriv){ alert( "Train cannot depart and arrive at the same station!" ); return false; } if ( document.getElementById('ReturnTravel').checked=true; { var valueDate = document.getElementById('OutwardDate').value; if ( valueDate== null || valueDate== '') { alert('Please provide an Outward Travel Date!'); return false; } } var valueRetDate = document.getElementById('ReturnDate').value; if ( document.getElementById('ReturnTravelType').checked==true && (valueRetDate== null || valueRetDate== '' )) { alert('Please provide a Return Travel Date!'); return false; } } Id appreciate any help anyone can share on this! Thanks. |