Jump to content

[SOLVED] Refresh page after inserting


timmah1

Recommended Posts

Hello,

 

I have a page (http://www.cheezyfries.net/plumbing/new_job.php) that you can input a new job with certain fields.

 

In the drop down menus, that are generated from the database, if your item isn't listed, you can list it by clicking a link that pops up a new window, you input the new item, and then close the window.

 

How can I make it so that just that field (drop-down menu) gets refreshed to show the new item without refreshing the whole page?

 

Any help would be greatly appreciated.

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/105600-solved-refresh-page-after-inserting/
Share on other sites

In you main page you'll need to add a function to add an option to the select

 

i.e.

function add_option(val, txt){
    var opt = document.createElement("option");
    opt.value = val;
    opt.txt = txt;
    document.getElementById('MY_SELECT_ID').appendChild(opt);
    document.getElementById('MY_SELECT_ID').selectedIndex = document.getElementById('MY_SELECT_ID').options.length - 1;
}

Not Tested

 

In the opened window, you'll need to call this function with the text and value;

i.e. you're using a link

<a href="#" onclick="window.opener.add_option('some value', 'some text'); window.close();">Select Me</a>

Again Not Tested.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.