Jak to mogę zrobić? Próbowałem tak i nie zadziałało.
<script type="text/javascript"> function init() { if (document.getElementById("url").value == 0) { document.getElementById("url").value = "wartośćdomyślna"; } else {document.getElementById("url").value = window.location.search; } } window.onload=init;</script>
Pole input:
<input type='text' name='app' value='domyslnawartość' id="url" readonly="readonly" />
Wstawianie wartościdomyślnej działa w IE i w Firefoxie, ale tylko po odświeżeniu strony. Chodzi o to, aby przy braku parametru wartość lądowała w polu input bez żadnego odświeżania strony. Teraz bez odświeżania strony to pole jest puste.
No i cały skrypt:
<script language='JavaScript' src='http://labenete.pl/jsval2.js'></script> <script type="text/javascript"> function init() { if (document.getElementById("url").value == 0) { document.getElementById("url").value = "wartośćdomyślna"; } else {document.getElementById("url").value = window.location.search; } } window.onload=init;</script> <script language='javascript' type='text/javascript'> function showRss_s() { document.subscribe_form_s.action='http://labenete.pl/rss_subscription.php'; document.subscribe_form_s.submit(); } </script><form name='subscribe_form_s' method='post' action='http://labenete.pl/responder.php' onSubmit='return validateform_s();'> <table width=70% cellpadding=2 cellspacing=2 border=0><tr><td colspan='2' align='center'><strong>Proszę podaj swoje Imię, adres Email i naciśnij wyślij.</strong></td></tr> <tr> <td align=right>Imię:</td> <td><input type=text size=20 name='Name1' value=''></td> </tr> <tr> <td align=right>Email:</td> <td><input type=text size=20 name='Email1' value=''></td> </tr> <tr> <td align=right></td> <td><input type='text' name='app' value='wartośćdomyślna' id="url" readonly="readonly" /></td> </tr> <tr> <td colspan=2 align=center><input type='submit' name='00submit00' value=' >>>WYŚLIJ<<< '></td> </tr> </table> <input type=hidden name=campid value='8'> <input type=hidden name=optional_url value=''> </form>