View Full Version : function will not return value

08-21-2007, 02:50 AM

I am populating a field on my page using a php include. I am asking javascript to update another element with that field's value. The value written to the select input box is '1:Any Provider'.

The process works fine in Firefox. In IE6 it does not write.
the value nor does it throw an error. What am I doing wrong?

input form:
[PHP]<form method="post" action="" name="inputForm">
<label for="provider">Name of Provider</label><select class="input" name="provider" size="1" style="width: 20em"><?php nameprov();?></select>
<input type="button" name="button" value="Upload" onclick="postthis()">
<div id="status"></div>


The script in the head element:

function postthis(){
var provider = document.inputForm['provider'].value;
var report = document.getElementById("status");
var message="The Value of Provider Block is: " + provider;
report.innerHTML = message;

In firefox, "The Value of Provider Block is: 1:Any Provider" is written in the report element.

In IE6, "The Value of Provider Block is : " is written in the report element.



Arty Effem
08-21-2007, 03:04 AM
<select class="input" name="provider" size="1" style="width: 20em"><?php nameprov();?></select> I'm guessing that the select's options are being generated without value parameters.

08-21-2007, 11:05 AM
We have to see the HTML generated code by the php <?php nameprov();?>

08-21-2007, 01:01 PM

function nameprov(){
$conn = mysql_connect( $domain, $user, $password );
$db = "";
$rs = mysql_select_db($db, $conn) or die("Err:Db");
$sql="select provId, provname FROM provider";
echo ("<option>" . $row['provId'] ." : ".$row['provname'] ."</option>" );

Possible that I have something turned off in IE that should be turned on? I checked but I can't see it.

I seem to have an ongoing problem with IE processing generate content improperly but processes static content properly within the same context.

Thanks for the look,


Arty Effem
08-21-2007, 01:12 PM
echo ("<option>" . $row['provId'] ." : ".$row['provname'] ."</option>" );As I guessed, you are not supplying a value parameter to the options, therefore you can't read their value.

08-21-2007, 02:48 PM
Yes, your options have no value. You need that value by all means in case you want to submit something.

Try to modify the php line in function like this:

echo ("<option value=\"". $row['provId'] ." : ". $row['provname'] ." \">" . $row['provId'] ." : ".$row['provname'] ."</option>" );

08-21-2007, 04:02 PM
Wonderful. End of that problem.

Thanks, Arty & Kor


08-21-2007, 04:09 PM
And in fact, you don't need the parenthesis (my ZEND says is incorrect), so that the correct code could be:

echo "<option value=\"". $row['provId'] ." : ". $row['provname'] ." \">" . $row['provId'] ." : ".$row['provname'] ."</option>";