English 中文(简体)
通过作为参数的“变数”
原标题:Passing php variable as parameter to javascript [duplicate]

我试图把 j印功能称作 j,一个论点是,从一个 drop子中可以变形。 只有在使用“这一价值”从现有跌幅箱中取出价值时,该笔文字才会奏效,然而,在试图通过变数时,该代码就没有工作。 当我使用重复性发言时,这一变量正从 drop箱的价值中适当分类。 我认为,问题实际上是将变数移至 j字功能。 该职能显示(q, r)项永远不会被称作书面声明从未执行。 希望得到任何帮助。 这里是我的实验室和javascript代码。

echo "<select name="course" onchange="showSection($q, this.value)">";
问题回答

(单位:千美元) 价值是扼杀性价值观,你必须在引言中予以采纳。

echo "<select name= course  onchange= showSection("$q", "this.value") >";

你们需要确保插入$q的数值。 这样做的合理办法是使用json_encode

之后,你需要确保以这种价值逃脱单一和双重报价,以保持正确性。 rel=“nofollow”>htmlspecialchars 此处使用。 我认为,将单一和双重报价永远转换(ENT_QUOTES)是最佳选择。

最终结果是(我在这里使用这个教义,因为我觉得可以阅读):

$escaped = htmlspecialchars(json_encode($q), ENT_QUOTES);
echo <<<HTML
<select name="course" onchange="showSection($escaped, this.value);">
HTML;




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签