Jump to content

JavaScript string processing from a form.


sepoto
 Share

Recommended Posts

What I am doing is checking for a null. I think I have not really crafted this properly. The form elements do contain a ' value="" ' in some cases. Should I be checking instead for ""? Do I need to convert window.physichaladdress to a string? This is the target line: if(window.physichaladdress != null) Thanks!

<?php?><!DOCTYPE html><html><head><title>My Title</title><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script><script>$(document).ready(function(){$('#enteraddress').hide();$('#entercoords').hide();$('#theyellow').hide();$("#radio01").click(function() {if ($(this).is(':checked')) { $('#enteraddress').show(); $('#theyellow').show(); $('#entercoords').hide();  }});$("#radio02").click(function() {if ($(this).is(':checked')) { $('#entercoords').show(); $('#theyellow').show(); $('#enteraddress').hide();  }});});</script><script type="text/javascript">function sepysfunction(){window.physichaladdress = document.mymapgetter.physichaladdress.value;window.thelat = document.mymapgetter.thelat.value;window.thelng = document.mymapgetter.thelng.value;if(window.physichaladdress != null) {alert("Alert Sepy!");}</script></head><body><form name="mymapgetter" action="action.php"><div style='border: solid 1px black; margin-bottom: 10px;' id="legaldisclaimer"><h1>Legal Disclaimer:</h1><p></p></body></div><div style='border: solid 1px black; margin-bottom: 10px;' id="locationoptions"><h3>How would you like to enter your location data?</h3><input type="radio" name="radio" value="" id="radio01">By physichal address?</input></br><input type="radio" name="radio" value="" id="radio02">By latitude and longitude?</input></div><div style='border: solid 1px black; margin-bottom: 10px;' id="enteraddress"><h3>Enter your physichal address:</h3></br><input type="text" name="physichaladdress" value="" style="width: 100%;"></input></div><div style='border: solid 1px black;' id="entercoords"><h3>Enter your latitude and longitude:</h3><input type="text" name="thelat" value=""><- Lat.</input><input type="text" name="thelng" value=""><- Lng.</input></div><input type="submit" id="theyellow" value="getmap" style="width: 100%" onClick="sepysfunction()"></input></form></html>

Link to comment
Share on other sites

I'm finding this to be a lot better:

<?php?><!DOCTYPE html><html><head><title>My Title</title><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script><script>$(document).ready(function(){$('#enteraddress').hide();$('#entercoords').hide();$('#theyellow').hide();$("#radio01").click(function() {if ($(this).is(':checked')) { $('#enteraddress').show(); $('#theyellow').show(); $('#entercoords').hide();  }});$("#radio02").click(function() {if ($(this).is(':checked')) { $('#entercoords').show(); $('#theyellow').show(); $('#enteraddress').hide();  }});});</script><script type="text/javascript">function sepysfunction(){window.physichaladdress = document.mymapgetter.physichaladdress.value;window.thelat = document.mymapgetter.thelat.value;window.thelng = document.mymapgetter.thelng.value;//alert("Alert Sepy!");if(window.physichaladdress == "") {alert("Alert Sepy!");}}</script></head><body><form name="mymapgetter"><div style='border: solid 1px black; margin-bottom: 10px;' id="legaldisclaimer"><h1>Legal Disclaimer:</h1><p></p></body></div><div style='border: solid 1px black; margin-bottom: 10px;' id="locationoptions"><h3>How would you like to enter your location data?</h3><input type="radio" name="radio" value="" id="radio01">By physichal address?</input></br><input type="radio" name="radio" value="" id="radio02">By latitude and longitude?</input></div><div style='border: solid 1px black; margin-bottom: 10px;' id="enteraddress"><h3>Enter your physichal address:</h3></br><input type="text" name="physichaladdress" value="" style="width: 100%;"></input></div><div style='border: solid 1px black;' id="entercoords"><h3>Enter your latitude and longitude:</h3><input type="text" name="thelat" value=""><- Lat.</input><input type="text" name="thelng" value=""><- Lng.</input></div><input type="submit" id="theyellow" value="getmap" style="width: 100%" onClick="sepysfunction()"></input></form></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...