Jump to content

document.form.selectbox has no properties after an AJAX call...


wrenbjor

Recommended Posts

ok this is what is going on. I have a standard html form and in it there is a <select> field. I fill this out with data from a database using PHP based off the user that is logged into the site. When I submit the form everything works great. Admins have the choice of filling out the form for someone else, so when they change the user from themselves to the new user then I have an AJAX call hit a page that loads that select box with the user id that was selected. This all works fine and the list is loaded with the new user's info, so I know the AJAX is working, but when I submit after the AJAX call I get a document.couse.idp (course is the form name) has no properties. Why is the part of the form I am loading no longer seen as part of the Main form... how can I fix this? ???

 

Here is the code from the form.

 

<input type="text" name="uid" size=40 maxlength=50 onChange="Javascript: ajax_loadContent('hridp','idp.php?uid='+document.course.uid.value);"> (Attached is the JS that this gets loaded from.

 

<div id="hridp">

<select name="idp" id="idp"><option value="0">Please Choose a Goal</option><option value="110011">No IDP Goal</option>

<?

$idp = run_sql_query("SELECT g.goal, g.plgid FROM hr_idp_goals g LEFT OUTER JOIN hr_idp i ON i.plid=g.plid WHERE i.uid=".$_SESSION["userid"]." and i.del=0", 'mysql', 'r', __LINE__);

 

while($g = mysql_fetch_assoc($idp))

{

?>

<option value="<?=$g["plgid"]?>"><?=$g["goal"]?></option>

<?

}

?></select>

</div>

 

 

Here is the code for the select being loaded into the DIV (idp.php). The ONLY difference between this and what is in the main form is the include line. That has to be there for the database connection.

 

<select name="idp" id="idp"><option value="0">Please Choose a Goal</option><option value="110011">No IDP Goal</option>

<?

include($_SERVER["DOCUMENT_ROOT"]."/include/main.php");

$idp = run_sql_query("SELECT g.goal, g.plgid FROM hr_idp_goals g LEFT OUTER JOIN hr_idp i ON i.plid=g.plid WHERE i.uid=".$_GET["uid"]." and i.del=0", 'mysql', 'r', __LINE__);

 

while($g = mysql_fetch_assoc($idp))

{

?>

<option value="<?=$g["plgid"]?>" <? if($g["plgid"]==$_GET["sel"]){ echo "SELECTED"; } ?>><?=$g["goal"]?></option>

<?

}

?></select>

 

[attachment deleted by admin]

Link to comment
Share on other sites

Oh fyi there is a security check that is generating the error.

 

else if(document.course.idp.selectedIndex == 0){

alert("Please provide the IDP goal that this course relates to.");

document.course.idp.focus();

}

 

this is what is making the "document.course.idp has no properties" error.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.