第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

用作 php 變量的 javascript 變量范圍用法

用作 php 變量的 javascript 變量范圍用法

湖上湖 2023-03-18 11:24:37
我想使用通過單擊地圖點 (mapbox) 獲得的 javascript 變量(電子郵件地址)。我想以 html/php 形式插入此變量作為 mailto 地址。但是我花了幾個小時試圖從 onclick 函數(shù)中獲取變量,但無濟(jì)于事。這是我最后一次嘗試:var agencyemail; map.on('click', 'unclustered-point', function (e) {agencyemail = e.features[0].properties.email; // the variable functions correctly within the onclick function... and then more}這顯然不起作用。從這里我想將捕獲的變量插入到 php 表單中 $et_email_to = '<script>document.write(agencyemail);</script>' ;    我也嘗試過使用 sessionStorage、localStorage 或 let,但我仍然沒有弄明白。感謝您的幫助。編輯:我使用了此處提出的解決方案。我只是將變量插入到表單隱藏字段值中。    map.on('click', 'unclustered-point', function (e) {    agencyemail = e.features[0].properties.email;    document.getElementById("agencyemail").value = agencyemail;...并在 html 中    <input type="hidden" value="" id="agencyemail" name="agencyemail"/> 謝謝您的幫助。
查看完整描述

1 回答

?
拉莫斯之舞

TA貢獻(xiàn)1820條經(jīng)驗 獲得超10個贊

map.on('click', 'unclustered-point', function (e) {

? ?var agencyemail = e.features[0].properties.email;?

? ?// the variable functions correctly within the onclick function... and then more

? ?// HERE is where you would use that variable to change something in a form, for example with jquery:

? ?$('a.mailto').prop('href','mailto:' + agencyemail);

}

如果你用一個<a class="mailto">元素創(chuàng)建你的 html 文檔,你可以看到它工作


這是假設(shè)var agencyemail = e.features[0].properties.email; 實際上會為您提供所需的信息,我無法驗證這一點。


查看完整回答
反對 回復(fù) 2023-03-18
  • 1 回答
  • 0 關(guān)注
  • 88 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號