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

If Statements and SelectIndex

P: n/a
Hi

I am trying work out a If statment, that uses a select statement as its
condition. In index.html I have the following:

function selectCar(){
var cars = ["Holden","Ford","Mercedes"]
var theSel = top.topFrame.document.fmCar.selectCar;
var opt = theSel.options;
for(i=0;i<cars.length;i++){
var carVal = cars[i];
opt[i] = new Option(carVal, carVal)
}
theSel.selectedIndex = Math.floor(Math.random()*cars.length);
}
function showSelect(){
var i=0;
var Holden = new Array (3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6,
14.2, 10.3, 6.6, 4.8)
var Ford = new Array (3.5, 4.9, 6.9, 10.4, 13.6, 17.3, 18.7, 18.1,
16.2, 16.2, 12.3, 7.2, 3.5)
var Mereceds = new Array(7.2, 8.3, 10.5, 13.7, 17.8, 21.7, 24.4,
24.1, 20.9, 16.6, 11.7, 8.4, 15.4)
var j = main1.mainframe.document.
=>Want I want here is to happen is that if the operator selects say
'Holden' it updates the table on main1.html<=
</script>
</head>

<frameset rows="100,*" frameborder="no" border="0" framespacing="0">
<frame src="topCar.html" name="topFrame" scrolling="No"
noresize="noresize" marginwidth="0" marginheight="0" id="topFrame" />
<frame src="main1.html" name="mainFrame" scrolling="No" marginwidth="0"
marginheight="0" id="mainFrame" />
</frameset>
<noframes><body>
</body>
</noframes></html>
main1.html looks like
<tr>
<td class="borderR">&nbsp;</td>

<td class="borderBR"><p align="right">3.5 </p></td>
<td class="borderBR"><p align="right">4.9 </p></td>
<td class="borderBR"><p align="right">6.9 </p></td>
<td class="borderBR"><p align="right">10.4 </p></td>
<td class="borderBR"><p align="right">13.6 </p></td>
<td class="borderBR"><p align="right">17.3 </p></td>
<td class="borderBR"><p align="right">18.7 </p></td>
<td class="borderBR"><p align="right">18.1 </p></td>
<td class="borderBR"><p align="right">16.2 </p></td>
<td class="borderBR"><p align="right">12.3 </p></td>
<td class="borderBR"><p align="right">7.2 </p></td>
<td class="borderBR"><p align="right">3.5 </p></td>
</tr>
</table>
Could someon advice me on how to achieve this.

Greg

Sep 18 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

Gregc. wrote:
Hi

I am trying work out a If statment, that uses a select statement as its
condition. In index.html I have the following:

function selectCar(){
var cars = ["Holden","Ford","Mercedes"]
var theSel = top.topFrame.document.fmCar.selectCar;
var opt = theSel.options;
for(i=0;i<cars.length;i++){
var carVal = cars[i];
opt[i] = new Option(carVal, carVal)
}
theSel.selectedIndex = Math.floor(Math.random()*cars.length);
}
function showSelect(){
var i=0;
var Holden = new Array (3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6,
14.2, 10.3, 6.6, 4.8)
var Ford = new Array (3.5, 4.9, 6.9, 10.4, 13.6, 17.3, 18.7, 18.1,
16.2, 16.2, 12.3, 7.2, 3.5)
var Mereceds = new Array(7.2, 8.3, 10.5, 13.7, 17.8, 21.7, 24.4,
24.1, 20.9, 16.6, 11.7, 8.4, 15.4)
var j = main1.mainframe.document.
=>Want I want here is to happen is that if the operator selects say
'Holden' it updates the table on main1.html<=
</script>
</head>

<frameset rows="100,*" frameborder="no" border="0" framespacing="0">
<frame src="topCar.html" name="topFrame" scrolling="No"
noresize="noresize" marginwidth="0" marginheight="0" id="topFrame" />
<frame src="main1.html" name="mainFrame" scrolling="No" marginwidth="0"
marginheight="0" id="mainFrame" />
</frameset>
<noframes><body>
</body>
</noframes></html>

Could you point us to the actual page? A URL? I was going to recreate
this, but with the frames it seems like a lot of work to recreate. What
are you hoping to achieve by using frames, anyway?

Sep 18 '06 #2

P: n/a

Jake Barnes wrote:
Could you point us to the actual page? A URL? I was going to recreate
this, but with the frames it seems like a lot of work to recreate. What
are you hoping to achieve by using frames, anyway?

I've nearly worked it out. Can't understand what's the big deal with
frames.

Greg

Sep 19 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.