Jump to content
Sign in to follow this  
sepoto

JavaScript string processing from a form.

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>

Share this post


Link to post
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>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...