473,395 Members | 1,823 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,395 software developers and data experts.

Changing HTML on the fly

Hi, I have a webpage where I want to have a select list which the user
can select between two different pictures, and then the chosen picture
loads onto the html page, but without having to reload the actual page.

At the moment, what I have is a select list as shown below:

<form name="orders">
<select name="picture" size="1">
<option value="pic1.jpg">Picture 1</option>
<option value="pic2.jpg">Picture 2</option>
</select>
<input type="button" name="btnSubmit" value="Submit Form"
onClick="submitForm();"/>
</form>

What I want this to do, is to change the code of the applet used so
that it loads a different picture into the applet. THe code for the
applet is:

<applet name="Jigsaw" archive="Jigsaw.jar" codebase="/jar/"
code="Jigsaw.class" width="800" height="600">
<param name=Image value="/pictures/pic1.jpg">
<param name=ImgWidth value=500>
<param name=ImgHeight value=375>
<param name=Rows value=4>
<param name=Cols value=4>
<param name=DimHelpImage value=60>
<param name=AutoSnap value=9>
<param name=MessageText value="You solved it!">
</applet>

Then in the submit form, I don't know what to put to get it to change
the picture. I can read the value for the Image parameter by using:

function ActionDeterminator()
{
pic= document.applets[0].getElementsByTagName('param')[0].value;
}

But I don't know whether or how I can write a value from the select
list to the parameter. I can receive the value of the select list with
this code:

document.orders.picture.options[document.orders.picture.selectedIndex].value;

I was wondering if it would be best to create a html file for each
picture, and create the applet dependant for each picture (although
this is a lot of re-use of html for no reason), and put it in an iframe
on each page. But then again, I don't know how to change the url for
an iframe depending on which item was selected from a select list.

Hopefully someone can help with this :)

thanks in advance,

David

Jul 23 '05 #1
1 2033
David wrote:
[...]
<form name="orders">
<select name="picture" size="1">
<option value="pic1.jpg">Picture 1</option>
<option value="pic2.jpg">Picture 2</option>
</select>
<input type="button" name="btnSubmit" value="Submit Form"
onClick="submitForm();"/>
</form>

What I want this to do, is to change the code of the applet used so
that it loads a different picture into the applet. THe code for the
applet is:

<applet name="Jigsaw" archive="Jigsaw.jar" codebase="/jar/"
code="Jigsaw.class" width="800" height="600">
<param name=Image value="/pictures/pic1.jpg">
[...]
</applet>

Then in the submit form, I don't know what to put to get it to change
the picture. I can read the value for the Image parameter by using:

function ActionDeterminator()
{
pic= document.applets[0].getElementsByTagName('param')[0].value; ^^^^^^^^^^^^^^^^^^^^ }
It would make more sense to access properties of the public class of
the applet instead of using a possibly unsupported DOM Level 2 method.
But I don't know whether or how I can write a value from the select
list to the parameter. I can receive the value of the select list with
this code:

document.orders.picture.options[document.orders.picture.selectedIndex].value;

This is proprietary referencing; should be both standards compliant and
downwards compatible

... document.forms['orders'].elements['picture'].options[
document.forms['orders'].elements['picture'].selectedIndex].value ...

or

var oSelect = document.forms['orders'].elements['picture'];
... oSelect.options[oSelect.selectedIndex].value ...

Probably you are looking for this:

<form ...
onsubmit="var oSelect = this.elements['foo'];
... = oSelect.options[oSelect.selectedIndex].value;
return false;">
...
</form>
[...] But then again, I don't know how to change the url for
an iframe depending on which item was selected from a select list.


referenceToHTMLIFrameElementObject.src = selectedValue;

Please read the FAQ.
PointedEars
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Brandon Hoppe | last post by:
I'm trying to change the src of an ilayer in the parent document from a link inside the ilayer. I'm not able to get it to work. All that happens is Netscape 4 crashes. This is for Netscape 4 only....
5
by: Jim Marquardson | last post by:
Hi, I've struggled with this for a while now, so I'm asking for help. I am trying to click on a link in one page, have that link open up in a new window, and set that newly opened window's...
31
by: Arthur Shapiro | last post by:
I'm the webmaster for a recreational organization. As part of one page of the site, I have an HTML "Calendar at a Glance" of the organization's events for the month. It's a simple table of a...
2
by: DartmanX | last post by:
I doubt this is possible, but I want to ask, just in case it is. I have a project going using Google Maps. This project spits out an HTML page template for people to post to their website and...
1
by: Tobe | last post by:
In the 2003 Visual Studio.NET, when switching between the HTML tab and the Design tab, the HTML changes format into something less readable. I have turned off the automatic formatting for HTML...
3
by: Jeremy Ames | last post by:
I have a form that contains two hidden values, among other controls. I was wondering, if I change these values in server script and immediately do a server.transfer, do these values get updated...
2
by: Joe | last post by:
Hi, I have a website with a mix of static (.html) and dynamic pages (.aspx) pages. I was wondering to change extension .html to .aspx , only to accommodate future needs of making static pages...
2
by: John Dalberg | last post by:
The below html validates correctly on w3.org's html validator when the file has an html extension. When the same file gets an aspx extension, I get the error below from the validator. This tells me...
12
by: GaryDean | last post by:
In the original post I failed so indicate that I am using framework 1.1....... I need to be able to change the background color of a page from code. I found an answer to this question in...
6
by: reynard | last post by:
I have a page that uses this doctype <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> but when I change to this: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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,...

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.