Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Jul 2006
    Posts
    171
    Thanks
    13
    Thanked 1 Time in 1 Post

    function will not return value

    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. [PHP]the value nor does it throw an error. What am I doing wrong?

    input form:
    PHP Code:
    <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:
    PHP Code:
    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

  • #2
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by 1andyw View Post
    Code:
    <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.

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    We have to see the HTML generated code by the php <?php nameprov();?>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    Regular Coder
    Join Date
    Jul 2006
    Posts
    171
    Thanks
    13
    Thanked 1 Time in 1 Post
    Hi,

    PHP Code:
    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

  • #5
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by 1andyw View Post
    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.

  • Users who have thanked Arty Effem for this post:

    1andyw (08-21-2007)

  • #6
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    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:
    PHP Code:
    ...
    echo (
    "<option value=\""$row['provId'] ." : "$row['provname'] ." \">" $row['provId'] ." : ".$row['provname'] ."</option>" );
    ... 
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • Users who have thanked Kor for this post:

    1andyw (08-21-2007)

  • #7
    Regular Coder
    Join Date
    Jul 2006
    Posts
    171
    Thanks
    13
    Thanked 1 Time in 1 Post

    Thumbs up

    Wonderful. End of that problem.

    Thanks, Arty & Kor

    Andy

  • #8
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    And in fact, you don't need the parenthesis (my ZEND says is incorrect), so that the correct code could be:
    PHP Code:
    ...
    echo 
    "<option value=\""$row['provId'] ." : "$row['provname'] ." \">" $row['provId'] ." : ".$row['provname'] ."</option>";
    ... 
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •