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

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.