473,769 Members | 6,799 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Swapping text and images

1 New Member
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 1370
Logician
210 New Member
<select name="Style" onchange="swap( this.options[selectedIndex].value)", "swapText('Prod uct 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
2955
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="#" onMouseOver="document.main.src='image2.jpg'"
2
1586
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 trying to do image swapping This snippet will prevent 'null' from appearing initially and successfully records user changes (typing in a comment)
3
2087
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 would also appreciate any general criticism you have to offer. I don't know yet how to write the degradation-path code for browsers that don't support the DOM methods I'm using, so there are some commented-out paths below. If the content...
1
5295
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 document.write(randomHeader) in the chooseHeader() function, but the rest of the page doesn't get displayed with that approach. Instead, what I would like to do is comment the document.write(randomHeader) line, and use the random reference I have in the table cell...
7
1291
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 = x.src; x.src = y.src; y.src = pictemp; }
6
2267
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 only. http://www.casespace.net I designed it with firefox (plus the autohide extension) in mind, but also want to support IE. Online and offline it works great in Firefox. Offline it also works
2
2130
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 = URLtoPictureOnWebServer.src; I cant get it to work with:
3
1367
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 deal with the intImage value? Cheers
1
1052
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 replaced, after eight more seconds, with the original image. For some reason, JavaScript keeps swapping the images back and forth endlessly -- and not even properly counting out all the seconds specified, after the first time swapping! What's...
0
9590
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10000
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8879
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3968
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.