עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

גישה לאלמנט בטופס דרך JavaScript

Featured Replies

פורסם

האם יש אפשרות לגשת לאלמנט בטופס דרך JS ישירות כשהעמוד עולה, ולא ע"י פעולה כגון OnClick שקוראת לפונקציה?

פורסם

מה אתה רוצה לעשות ?

פורסם
  • מחבר

הסתדרתי. תודה.

פורסם

מצאת תשובה, ולא רשמת אותה ל"דור ההמשך". בכל מקרה, הפתרון הוא להשתמש באירוע onload של הBODY כך:



...
<body onload="javascript: myFunction(); ">

...


אם פשוט לרשום את קוד הJS מחוץ לפונקציה כלשהי, כך:



<script type="text/javascript">
var bla;
myCode();
someMoreCode();
document.write("hello world");
...

</script>

פורסם

נהוג לרשום ב-head ולא סתם בחלל האויר

פורסם
  • מחבר

השתמשתי ב-window.onload שלמעשה עושה בדיוק את אותו הדבר שאתה אמרת.

גם את קוד הJS רשמתי בPHP באמצעות פקודת echo. בצורה זו הצלחתי לחבר בין משתנה שנתקבל מהשרת, לבין אלמנט בטופס שאליו התייחסתי באמצעות JS.

למשל:

echo "if (document.form1.placesradio.value=='".$optype."') {";

פורסם

נהוג לרשום ב-head ולא סתם בחלל האויר

כאשר רושמים את הסקריפט לא בפונקציה, לפעמים מחוייב לשים את הSCRIPT בBODY, מכיוון שלא מחוייב שהאובייקט נטען.

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.