Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Js.....transferring value from 1 select to another....but not shwoing in source.
Old 04-07-2010, 05:39 AM Js.....transferring value from 1 select to another....but not shwoing in source.
Isabella_Smith's Avatar
Ultra Talker

Posts: 285
Trades: 0
Hi,

Here's the function I am using to change the value of one select to another....

PHP Code:
function transferItem(srcIddestId) {
var 
destObj document.getElementById(destId);
var 
srcObj document.getElementById(srcId);
for(var 
i=0i<srcObj.lengthi++)
if(
srcObj.options[i].selected) {
var 
srcTxt srcObj.options[i].text;
var 
srcVal srcObj.options[i].value;
var 
newOpt document.createElement("OPTION");
newOpt.text srcTxt;
newOpt.value srcVal;
destObj.add(newOptnull);
}
for(var 
i=0i<srcObj.lengthi++) {
if(
srcObj.options[i].selected) {
srcObj.remove(i);
}
}

I can see it is transferring one select to another but when I check the source....I shows empty.....

Please help...

Here's the code how I am calling it...

HTML Code:
<select name="cat[]" id="cat" multiple="multiple" size="10" style="width: 200px;">
                                                 <option onKeyPress="" value="Select City">Select Category</option>
</select>

<input name="insert" type="button" onClick='transferItem("cat","cat2") ' class="btm" value="Insert" /></td>

<input name="delete" type="button" onClick='transferItem("cat2","cat") ' class="btm" value="Delete" />

 <select name="cat2[]" id="cat2" multiple="multiple" size="10" style="width: 200px;">
</select>
In the last:

This is how I am calling this array:

PHP Code:
if(!empty($_POST['cat2']))
    {
    
        for(
$i=0$i<sizeof($_POST['cat2']); $i++)
        {
        
        
$list1[$i] = $_POST['cat2'][$i];
                        
        } 
Please help.....Thanks..
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
buy all indian salwar Kameez, Sarees and clothes

Last edited by Isabella_Smith; 04-07-2010 at 05:47 AM..
Isabella_Smith is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-07-2010, 05:57 AM Re: Js.....transferring value from 1 select to another....but not shwoing in source.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Javascript works on the object model of the page in memory NOT on the physical source.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-07-2010, 06:02 AM Re: Js.....transferring value from 1 select to another....but not shwoing in source.
Isabella_Smith's Avatar
Ultra Talker

Posts: 285
Trades: 0
Thanks, Chrishirst,

So, Is there any solution..???as I want to transfer it physically so that my php function would be able to recognize that.......

Please help.

Thanks,
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
buy all indian salwar Kameez, Sarees and clothes

Last edited by Isabella_Smith; 04-07-2010 at 06:09 AM..
Isabella_Smith is offline
Reply With Quote
View Public Profile
 
Old 04-07-2010, 06:24 AM Re: Js.....transferring value from 1 select to another....but not shwoing in source.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Even if there was PHP would NOT "recognise" it.

PHP is over and done BEFORE the page is rendered in the browser and javascript starts to run.

PHP is SERVER SIDE code and has NO interaction with client side code.

You have to PASS the values BACK to the server by submitting the form (POST method) or making another request to the server with querystring parameters (GET method)
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Js.....transferring value from 1 select to another....but not shwoing in source.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.86506 seconds with 12 queries