473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Swapping text and images

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="http://us.2.p9.webhosting.yahoo.com/forms?login=vansawardsplus" 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="http://www.alwaysinmyheartinc.com/noform/68chsa.htm">
  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
1 1351
Logician
210 100+
<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

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

Similar topics

5
by: Richard | last post by:
I'm beginning to undertake php for the fun of it. Working on a problem I hope can be solved in php. Basically what I have is this: <body> <img name="main" src="image1.jpg"> <a href="#"...
2
by: uNConVeNtiOnAL | last post by:
Hi - I have a page that has a button that makes a prompt appear for the user to type input. When they have typed in input, I want the button to change color when the prompt closes. I am...
3
by: Christopher Jeris | last post by:
Please help me understand the differences, in semantics, browser support and moral preferredness, between the following three methods of swapping content in and out of a page via JavaScript. I...
1
by: Terry Haufler | last post by:
I am trying to swap/rotate random flash banners using the following Javascript code. I have 3 flash headers/banners. I can get it to open a page with a random header using...
7
by: Jon Glazer | last post by:
I know this is sorta reposting but I want to simplify the issue a bit. Take the following script: function replacemain(s){ var x = document.images; var y = document.images; var pictemp =...
6
by: cjl | last post by:
I have a website which allows people to view interesting radiology cases. It is for teaching radiology residents. It is designed to run in fullscreen or 'kiosk' mode, at 1024 x 768 resolution...
2
by: TuftyTrue | last post by:
Hi, On my site the user can browse to an image with <input type=file etc>. Althrough I have no problem swapping images with: document.getElementById('PictureToDisplay').src =...
3
by: Geoff Cox | last post by:
Hello, Way back in 2000 Ken Cox put up this code for swapping images on a button. I cannot work out how to use it so that more than 1 button can use it. I guess the problem is knowing how to...
1
by: Prisoner at War | last post by:
Hi, Everybody, The fucntion below is called by an onLoad <imgattribute, and it is supposed to replace the original image, after three seconds, with another image. This second image shouldl be...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.