Forum Moderators: open

Message Too Old, No Replies

Pass iframe onchange

         

Unregistered

5:54 pm on Mar 31, 2008 (gmt 0)

10+ Year Member



Ok, Firstly, Its going to be obvious that I'm pretty unclear as to what I'm doing here, but I've been tasked with getting this together so here I am. I have everything I need save one small issue. I need to pass the text of a drop down selection, but I seem to only be able to pass the default value.

Now I used a bunch of this code from a generator, a walk through page, and some other sources. I hacked the hell out of it and its likely very ugly but it does what I need so I apologize in advance.

<p>
<select onchange="window.open(this.options[this.selectedIndex].value,'iframe');this.selectedIndex=0;" name="config">
<option value="instructions.html"> Configuration Options </option>
<option value="option1.html"> Configuration option 1 </option>
<option value="option2.html"> Configuration option 2 </option>
<option value="option3.html"> Configuration option 3 </option>
<option value="option4.html"> Configuration option 4 </option>
</select>
</p>

So it shows the right .html in the iframe, I just need to pass the pull down text of each option, how would I go about this?

Thanks again for bearing with my newbieness.

Unregistered

6:22 pm on Mar 31, 2008 (gmt 0)

10+ Year Member



Oh, and I also have this for my iframe:

<iframe name="iframe" src="instructions.html" align="top" height="460" width="760"></iframe>

Unregistered

6:26 pm on Mar 31, 2008 (gmt 0)

10+ Year Member



ok It seems I figured out how to get it to pass the value, by changing the "this.selectedIndex=0" to "this.selectedIndex=option". So thats a step in the right direction. I'm going to keep hacking away to see if I can get this Frankenstein to work..

Thanks for any input!

Trace

7:04 pm on Mar 31, 2008 (gmt 0)

10+ Year Member



Hey, I think this is what you're trying to do;
(let me know if I misunderstood you)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title> New Document </title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>

<form action="" method="">
<fieldset>
<legend>The list box</legend>
<select onchange="sendValue(this);" name="config">
<option value="instructions.html"> Configuration Options </option>
<option value="option1.html"> Configuration option 1 </option>
<option value="option2.html"> Configuration option 2 </option>
<option value="option3.html"> Configuration option 3 </option>
<option value="option4.html"> Configuration option 4 </option>
</select>
</fieldset>
</form>

<script type="text/javascript">
function sendValue(myObj){
newLocation = myObj.options[myObj.selectedIndex].value;
document.getElementById('theFrame').src = newLocation;
}
</script>

<iframe id="theFrame" name="iframe" src="instructions.html" align="top" height="460" width="760"></iframe>

</body>
</html>

Unregistered

7:52 pm on Mar 31, 2008 (gmt 0)

10+ Year Member



Looks pretty much the same as what I have, ascetics and function wise. I likely should have clarified. I am trying to pull the text "configuration option N" and pass it to a script and dump to an email. I can get the "optionN.html" to pass with my above. Your code is radically different from mine. so I'm not exactly sure where to begin.

It looks like the pulldown is simplified greatly. And the script is separated out of the actual pulldown? The function will send the text? or the actual value?

Thanks for your help, and sorry I'm such a newb.
I was hoping there would be some easy way to do this. Like labeling each option in the pull down or changing the this.selectedIndex= to something.

Trace

8:02 pm on Mar 31, 2008 (gmt 0)

10+ Year Member



I see - yeah, what I did is nothing like that. The only thing my above code will do is change the location of the frame to whatever option is selected in the drop down. Not at all what you are looking for.

Am I understanding you correctly now? All you want to do is take the text "configuration option N" and have it sent to the iframe? (the iframe I assume conatins the script that will send the email)

What confuses me is what is value="option N .html" for?

Unregistered

8:15 pm on Mar 31, 2008 (gmt 0)

10+ Year Member



The optionN.html displays a page with all the configuration options in the iframe. I just want to pull the name of the configuration to the email to send it out, but seem to only be able to pull the value, which is the html page filename. The script pulls everything else fine, but I can't get it to pull the "configuration option N".

Thanks again for your time, I really appreciate your help!

Unregistered

3:49 pm on Apr 3, 2008 (gmt 0)

10+ Year Member



ok I got it working how I needed.

Thanks for your Help Trace, I just don't know enough to have anyone help me it seems, shy of teaching me how to do it from the get go:P

So I just renamed my html files to these really long sentences with all the info I needed and stripped the file extension off. It still displays properly, and gives me exactly what I need.

thanks anyhow!