Click to See Complete Forum and Search --> : js text input population problems


gvimercati
09-09-2003, 03:46 AM
hello,

quick question... i'm using javascript to populate two text boxes within a form... post code and town code(dependant on a drop down box selection)... this all works fine and populates the input boxes without problems only that when i submit the form... the values dont get passed to the next page. Is there a way around this that anyone can help me with?

Khalid Ali
09-09-2003, 05:54 AM
this does not splaing what problem you might have in your code.

You should have posted at least.

1. an error that you are getting,
2. the code which you are using to pass the data to the next page

gvimercati
09-09-2003, 07:35 AM
hi Khalid,

i dont have errors... it simply doesn't pass the values generated by the js to the following page.

the code i use is below thought...

function changecomres(value, flag)
{
if (flag =='Nas') {
window.open('/xxxxx/detcom.php?tipo=1&pro='+value, //other window settings);
}
else {
window.open('/xxxxx/detcom.php?tipo=2&pro='+value, //other window settings);
}
}

//the following select is part of the main form that has truble passing the values
<select name="ProNas" class="textbox2" onchange="javascript:changecomres(this.value, 'Nas')">


**********detcom.php**********

function vai()
{

thisval = document.comune.com.value.split("***");
prov = thisval[0];
cap = thisval[1];
<?php
if ($tipo==1) {
?>
window.self.close();
window.opener.step.ComNas.value = prov;
window.opener.step.focus();
<?php
}
else if($tipo==2) {
?>


window.self.close();
window.opener.step.ComRes.value = prov;
window.opener.step.CAP.value = cap;
window.opener.step.focus();
<?php
}
?>
}

<html>
.
.
<form...>

$comuniStr = "SELECT * FROM table WHERE Province='".$pro."'";
echo "<table width=\"90%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\"><tr><td>
<select size=\"10\" name=\"com\" class=\"textbox\" onchange=\"vai();\">\n";

$comuni = mysql_query($comuniStr, $connessione) or die("error");

while ( $Comune=mysql_fetch_array($comuni) )
{
print("<option value='".$Comune['comuni']."***".$Comune['CAP']."'>".$Comune['comuni']."</option>");
}
</form>
.
.
</html>
********end detcom.php********

ps. the detcom file works without a problem... the input text fields get populated without a problem... i simply dont see the values once i post the form in the main file...

pps. 1 thing to note is the inputs that are populated by detcom are disabled... by i dont see that that would be an issue...

Hope this makes sence... if you need more info, let me know... thanks heaps...

gianni

Khalid Ali
09-09-2003, 10:11 AM
the way your code is,you should be able to get the values in the window.open() page using
var val = location.href.search;

gvimercati
09-10-2003, 09:53 AM
No need... found the issue,

It seems that IE does not sent diabled fields. I enable them and all worked fine. (I don't know how other browsers handle them, but its something i have to look into).

i enabled the input text boxes and added this line to them
onFocus="yourElementClickedOn.blur();".

thanks for ur help anyway,

gianni