By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,398 Members | 1,351 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,398 IT Pros & Developers. It's quick & easy.

Swapping text and images

P: 1
I know I saw a similar posting about this but mine is a little more complicated and being barely able to understand javascript, i am having a little trouble.

Expand|Select|Wrap|Line Numbers
  1. <FORM ACTION="" METHOD="post" NAME="Personalize" onsubmit="return ValidateForm();">
  2. <INPUT TYPE="hidden" NAME="form" VALUE="contactpage">
  3. <INPUT NAME="Subject" TYPE="hidden" SIZE=32 VALUE="Additional Information for 68CHSA">
  4. <INPUT NAME="Personalize" TYPE="checkbox" VALUE="No"> No Personalization&nbsp; 
  5. <p>
  6.             <input type="hidden" name="on0" value="Style">
  7.     <select name="Style" onchange="swap(this.options[selectedIndex].value)", "swapText('Product Description: 6X8 Gray Speckled Plaque. Plain Bordered plate 
  8.         with a poem by Carol Huyser.')">
  9.      <option value="">Select a Border
  10.     <option value="images/68chsa2lrg.jpg" name="Designer Border">Designer Border
  11.     <option value="images/68chsalrg.jpg" name="Plain Blue Border">Plain Blue Border
  12.     </select><br>
  13.     <input type="hidden" name="next_url" value="">
  14. <p><i>Your Email Address:</i><font color=red>*&nbsp; </font>&nbsp;<INPUT NAME="Email_Address" TYPE="text" SIZE=20 VALUE="">&nbsp;&nbsp;
  15. <input type="submit" value="Submit" name="Submitted_Successfully"><input type="reset" value="Reset" name="B2"></p>
  16. </form>
Thats the form I am working with. But i am having trouble with swapping out text. At first I was told to put what I wanted changed into a span and then id it and use javascript to change it so here is my coding for that.

Expand|Select|Wrap|Line Numbers
  1. <script 
  2. language="javascript">
  3. function swapText(what) {
  4. document.getElementById("myspanid").innerHTML=what; //this will change the HTML in myspanid to the HTML you specified when calling the function
  5. }</script>
And lastly here is where i want my text to change. But it has to be done when an option is selected from the dropdown menu.

Expand|Select|Wrap|Line Numbers
  1. <span id="myspanid">Product Description: 6X8 Gray Speckled Plaque. Designer Bordered plate 
  2.         with a poem by Carol Huyser.</span>
I can't figure out for the life of me why this code won't swap the text. Any help would be much appreciated.
Jun 23 '07 #1
Share this Question
Share on Google+
1 Reply

P: 210
<select name="Style" onchange="swap(this.options[selectedIndex].value)", "swapText('Product Description: 6X8 Gray Speckled Plaque. Plain Bordered plate
Use the JavaScript console.
Expand|Select|Wrap|Line Numbers
  1. onchange="swap(this.options[this.selectedIndex].value)"
There was only ever one browser that needed that syntax and it wouldn't support your function, so you could use:
Expand|Select|Wrap|Line Numbers
  1. onchange="swap(this.value)"
Jun 23 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.