timmah1 Posted July 16, 2008 Share Posted July 16, 2008 I have a form that people can fill out, it has a drop-down with different options, if their option isn't listed, they can click on a link and a pop-up pops up, they can enter their option, click on submit, and it automatically refreshes the drop-down with all values, including the new one. It works great with Firefox, but not IE. In IE, it makes the drop-down go blank. Here is the code The link for the pop-up <span class="style1">Job Type Not Listed?<br /><a href="javascript:loadWindow('pop_job_type.php');">Click Here</a></span> The form for putting new info into <script type="text/javascript"> function update(){ var vals = opener.document.form1.general_contractor.innerHTML; var newVal = document.getElementById('name').value; var finalVal = vals+'<option value="'+newVal+'">'+newVal+'</option>'; opener.document.form1.general_contractor.innerHTML = finalVal; document.theForm.submit(); } </script> <?php if($_POST['enter'] == "yes"){ include("config.php"); $insert = mysql_query("insert into contractors values ('NULL','".$_POST["name"]."','".$_POST["address"]."','".$_POST["office"]."','".$_POST["cell"]."','".$_POST["contact"]."','".$_POST["email"]."','".$_POST["type"]."')") or die("Sorry, there was a problem inserting contractor ".mysql_error()); echo "Contractor inserted into database"; ?> <br /><a href="javascript:window.close()" onclick="update();">Close This Window</a> <?php } else { ?> <form action="#" method="POST"> <h1>New Contractor</h1> This is where you will input a new contractor. <table cellspacing="0" cellpadding="5"> <tr> <td>Contractor Name</td> <td><input type="text" name="name" id="name"></td> </tr> <tr> <td>Contractor Address</td> <td><textarea name="address" id="address"></textarea></td> </tr> <tr> <td>Contractor Office</td> <td><input type="text" name="office" id="office" /></td> </tr> <tr> <td>Contact Cell</td> <td><input type="text" name="cell" id="cell" /></td> </tr> <tr> <td>Contact Name</td> <td><input type="text" name="contact" id="contact" /></td> </tr> <tr> <td>Contact Email</td> <td><input type="text" name="email" id="email" /></td> </tr> <tr> <td>Contractor Type</td> <td><select name="type" id="type"> <option value="General">General</option> </select> </td> </tr> <tr> <td> </td> <td><input type="hidden" name="enter" id="enter" value="yes" /> <input type="submit" name="button" id="button" value="Submit" onclick="update();" /></td> </tr> </table> </form> <?php } ?> Any ideas on how I can fix this? Thanks in advance Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted July 18, 2008 Share Posted July 18, 2008 ya know Holy. Crap. I beg of you people to put OR die(mysql_error()) after your queries so you can see what's going on. =/ /\ Not everyone uses mysql and not all the other database have that function.. like mssql for instance Quote Link to comment Share on other sites More sharing options...
timmah1 Posted July 18, 2008 Author Share Posted July 18, 2008 wow, thanks for the reply to my question. maybe next time i'll ask a question about my signature and you could answer the question Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted July 18, 2008 Share Posted July 18, 2008 SUPER!!! thanks for asking... HAHAHA.. don't be an arse here is your fix... its another IE bug... (phew!! that was hard) ps..(@) see? we can all be arses Quote Link to comment Share on other sites More sharing options...
timmah1 Posted July 18, 2008 Author Share Posted July 18, 2008 I'm well aware of it being an IE bug, hence the reason why I came here to see if anybody had any idea of how to fix it Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted July 18, 2008 Share Posted July 18, 2008 are you sure your name is not literal lucy?? don't you think its obvious that we know that you know that this is an IE bug..? hence you posting it to be an IE bug..? all i'm sayin is hey i made a comment about your sig... whoopie frikin do man.. and you decided you would be an arse about it.. hence my being arse back to you telling you the fix is that there is not a fix because its an IE bug.. I was going to attempt to solve your problem but I see now that you do not want my help therefore I will be the better person and refrain from posting in this topic.. I said good day sir! Quote Link to comment Share on other sites More sharing options...
xenophobia Posted July 19, 2008 Share Posted July 19, 2008 var opt = document.getElementById('test'); // opt.options[the index element in the select list] opt.options[1] = new Option("This is the text", "This is the value"); Try this out. This will add an item into the list. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.