Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

label or value into a variable using JavaScript


fabriccut100

Recommended Posts

Posted

I was told that this could be a way of targeting this child list to the description field when I setup a new product

 

here is the list http://www.rolodesigns.com/test715/test1.php

 

I need to target the "add to list" button so when I click it it will show up in the product description field,

 

below is what I was told could work but I am at a loss and have no clue on how or where to put this so it works

 

isn't there anyone who knows anything about this and can help me I desperately need this, anyone? Please help

 

below is what I was told could be done.

 

You can pass a label or value into a variable using JavaScript and then

write that variable to the page to implement the display of the selected

item by adding a Call JavaScript client behavior to set the variable:

 

To do this put a JavaScript function in the head of your document:

 

<script type="text/JavaScript">

<!--

function SetVar() {

var MySelection;

MySelection=document.form1.selectList.options[document.form1.selectList.selected

Index].text;

alert(MySelection);

document.getElementById("varContainer").innerHTML = MySelection;

}

//-->

</script>

 

As you can see the variable "MySelection" is declared and then it is set

to the text (label) of the selectList form element. I added an alert for

testing purposes and commented it out. The next line sets the HTML text

in a DIV named "varContainer" to the value in the MySelection variable.

 

Next I added the trigger that calls the function to the onChange event

of the select list:

 

<select name="selectList" id="selectList" onchange="SetVar();">

 

Lastly, I added the div to the page to receive the text in the

MySelection variable:

 

<div id="varContainer"></div>

Posted

Okay, I'm not sure if this is what you mean, but in my product_info.php I call an external javascript from within the head tag, then use it within the product description for the product images.

 

Example:

 

<a href="http://adarkdesire.com/store/images/allure/13-110_5-126.jpg" rel="enlargeimage::mouseover" rev="loadarea">

<img src="http://adarkdesire.com/store/images/allure/tn13-110_5-126.jpg"></a> 

<a href="http://adarkdesire.com/store/images/allure/13-110_5-126_back.jpg" rel="enlargeimage::mouseover" rev="loadarea"><img src="http://adarkdesire.com/store/images/allure/tn13-110_5-126_back.jpg"></a>

<div id="loadarea" style="width: 400px" align="left">

<img src="http://adarkdesire.com/store/images/allure/13-110_5-126.jpg"></div>

 

You can see the actual product page here: http://adarkdesire.com/store/leather-lycra...ier-p-1143.html

 

Is this what you are talking about?

Posted

Thank you for you're quick response, I can't believe that no one knows how to do this, there must be someone who can help me with this oh well I guess it's back to the search engines to do some more digging, but thank you so much for responding I really appreciate you're time and kindness

 

Kelly

Posted
I was told that this could be a way of targeting this child list to the description field when I setup a new product

 

To do this put a JavaScript function in the head of your document:

 

<script type="text/JavaScript">

<!--

function SetVar() {

var MySelection;

MySelection=document.form1.selectList.options[document.form1.selectList.selected

Index].text;

alert(MySelection);

document.getElementById("varContainer").innerHTML = MySelection;

}

//-->

</script>

 

i tried looking at the url you provided, and it says that this area of the website is missing or under construction. so i'm unable to see what it happening. can you tell me what happens when this is executed? are you using firefox? if so, go to the tools menu and select 'error console.' any javascript errors will be output in that window and it helps to track down the errors.

 

i've also found that if the javascript is defined before the elements that the script accesses - this can lean to problems. without knowing specifically what error messages (if any) you're getting, my first suggestion would be to have your javascript defined after your <div id="varContainer">.

Posted

I apologize for the error here is the link again and I've checked it to make sure it's working http://www.rolodesigns.com/test715/test1.php

what I'm trying to do is use the target as my description when setting up new products but I notice that I can't even cut and paste it in my description from the taget list, there has to be a way of some how putting the target in, above, below the description field thanks for any help and I really appreciate your response

 

Kelly

 

 

i tried looking at the url you provided, and it says that this area of the website is missing or under construction. so i'm unable to see what it happening. can you tell me what happens when this is executed? are you using firefox? if so, go to the tools menu and select 'error console.' any javascript errors will be output in that window and it helps to track down the errors.

 

i've also found that if the javascript is defined before the elements that the script accesses - this can lean to problems. without knowing specifically what error messages (if any) you're getting, my first suggestion would be to have your javascript defined after your <div id="varContainer">.

Archived

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

×
×
  • Create New...