English 中文(简体)
a. 通过隐藏的iframe积极增加清单中的备选办法
原标题:Dynamically add options to a list through a hidden iframe

我想通过隐蔽的iframe,积极增加名单上的选项;我怀疑我的错误在于以下的PHP:

<?php echo  var oInner  = document.createTextNode(" .$donnees["name"]. "); ; ?>

由于我的法典与以下方面完全一致:

<?php echo  var oInner  = document.createTextNode("Newoption"); ; ?>

我不知道为什么造文no不想要拿我的购买力平价......。 我认为,这可能是同一个来源政策,因为数据库位于我网站上的一个服务器上。

我不知道。

You ll find enclosed the complete code:

在我的超文本中,我有:

//select or change a country will trigger the javascript part
<select name="countrym" id="countrym" onchange="validcountry();">
    <option value"France">France</option>
</select>

//Empty region list
<select name="regionm" id="regionm">
</select>

//My Iframe
<iframe name="upload_iframe2" id="upload_iframe2" frameborder="0"></iframe>

我在贾瓦特写道:

//My function triggering the PHP through the Iframe
function validcountry() {
var countrym = document.getElementById( countrym );
    var choixco = countrym.options[countrym.selectedIndex].value;
    document.getElementById( upload_iframe2 ).src =  region.php?choix= +choixco;

在我的PHP地区。 php档案,我有:

<?php

// Get my choice
$codepays = $_GET[ choix ];

//Retrieve the regions corresponding to the country
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bdd = new PDO(XXX);
$req = $bdd->prepare( SELECT name FROM regions WHERE country = :country );
$req->execute(array( country  => $codepays));
$donnees = $req->fetch();

while($donnees)
   {   
// I checked the format of the data (no problem so far)
echo var_dump ($donnees[ name ]);
?>

//I add an option through Javascript
<script language="JavaScript" type="text/javascript">
var oOption = document.createElement("option");

//Here is my big issue:
<?php echo  var oInner  = document.createTextNode(" .$donnees["name"]. "); ; ?>

oOption.value = "none";
oOption.appendChild(oInner);
var parDoc = window.parent.document;
var regionm = parDoc.getElementById("regionm");
regionm.appendChild(oOption);
</script> 

<?php
$donnees = $req->fetch();
}
$req->closeCursor();
exit();
?>
问题回答

您是否只尝试了oOption.inner/60/8 = <? php呼应了美元“名称”?> ;?

I am suspecting that the indexed element cannot be found. But is all cases, this below should work.

<?php echo  var oInner  = document.createTextNode(" . (isset($donnees["name"]) ? $donnees["name"] :   ) . "); ; ?>

Found the solution: it was the php inserting so the solution is to do the following:

$desc=  var oInner  = document.createTextNode(" .$donnees["name"]. "); ;
$desc=  str_replace("
", "",$desc);
$desc=  str_replace("
", "",$desc);

感谢大家





相关问题
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.

热门标签