yeahz Posted September 25, 2009 Report Share Posted September 25, 2009 (edited) Kāpēc pēc šāda koda: <script type="text/javascript"> function notEmpty(elem, elem2, elem3){ if (elem.value.length == 0 || elem.value == "Message..."){ alert('Don\'t leave empty Message field!'); elem.focus(); return false; } else if (elem2.value.length == 0 || elem2.value == "Your name..."){ alert('Don\'t leave empty Your name field!'); elem2.focus(); return false; } else if (elem3.value.length == 0 || elem3.value == "Your email (will not be published)..."){ alert('Don\'t leave empty Your email field!'); elem3.focus(); return false; } else { return true; } } </script> nospiežot OK pēc alerta paziņojuma, lapa pārlādējas? Es nergibu lai pārlādejas. Edited September 25, 2009 by yeahz Quote Link to comment Share on other sites More sharing options...
briedis Posted September 25, 2009 Report Share Posted September 25, 2009 No kurienes tiek izsauktas funkcija? ja no <a> tag`a, tad, ja onclick funkcija atgriež true, tiek izpildīts href lauks... <a href="http://www.google.lv" onclick="doSmtn(1);">Ejam uz gūgli</a> <a href="http://www.google.lv" onclick="doSmtn(2);">NEEJAM uz gūgli</a> <script> function doSmtn(i){ if(i == 1){ return true; } if(i == 2){ return false; } } </script> Quote Link to comment Share on other sites More sharing options...
xPtv45z Posted September 27, 2009 Report Share Posted September 27, 2009 briedi, tavi abi piemēri vienmēr aizies uz google.lv :) Lai ņemtu vērā funkcijas atgriezto rezultātu, tad ir jāraksta onclick="return doSmtn(2);" Quote Link to comment Share on other sites More sharing options...
briedis Posted September 27, 2009 Report Share Posted September 27, 2009 briedi, tavi abi piemēri vienmēr aizies uz google.lv :) Lai ņemtu vērā funkcijas atgriezto rezultātu, tad ir jāraksta onclick="return doSmtn(2);" Jā, sorry, mana neuzmanības kļūda :( Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.