...

View Full Version : function will not return value



1andyw
08-21-2007, 02:50 AM
Hi,

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>

</form>

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.

Thanks,

Andy

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.

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

1andyw
08-21-2007, 01:01 PM
Hi,


function nameprov(){
$domain="";
$user="";
$password="";
$conn = mysql_connect( $domain, $user, $password );
$db = "";
$rs = mysql_select_db($db, $conn) or die("Err:Db");
$sql="select provId, provname FROM provider";
$rs=mysql_query($sql,$conn);
while($row=mysql_fetch_array($rs)){
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,

Andy

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.

Kor
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>" );
...

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

Thanks, Arty & Kor

Andy

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>";
...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum