Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run script from dropdown without using a button

Status
Not open for further replies.

tav1035

MIS
May 10, 2001
344
US
I have a dropdown that I would like to run a script.
Can't seem to get it....
Here is the scripts that I would like to run which passes text from first textbox to the second textbox while appending text->
Code:
<script language=&quot;JavaScript&quot;>
<!-- Begin
function passText(str) {
document.myform.select.value = &quot;Where WORKORDER.WONUM in ('&quot; + str + &quot;')&quot;;
}
// End -->
</script>
 
<script language=&quot;JavaScript&quot;>
<!-- Begin
function passText2(str) {
document.myform.select.value = &quot;Where WORKORDER.LEADCRAFT in ('&quot; + str + &quot;')&quot;;
}
// End -->

</script>

Here is the dropdown and textboxes->
Code:
    <!-- Form Start -->
<form name=&quot;myform&quot;>

    <!-- First Textbox Start -->
<textarea rows=&quot;9&quot; name=&quot;user&quot; cols=&quot;45&quot; onBlur=&quot;this.value = convertSpaces(this.value);&quot;></textarea>
<input type=&quot;reset&quot; value=&quot;Reset&quot; name=&quot;B2&quot;>
    <!-- First Textbox End -->

    <!-- DropDown Start -->
<select name=&quot;select1&quot; onChange=&quot;document.myform.submit()&quot;> 
<option>Select one:
<option value= onChange=&quot;this.value = passText
(this.form.user.value);&quot;>Workorder
<option value= onChange=&quot;this.value = passText2
(this.form.user.value);&quot;>Leadcraft
</select>
    <!-- DropDown End -->

</tr>
</td>
<td width=&quot;50%&quot; align=&quot;center&quot;>

    <!-- Second Textbox Start -->
<textarea rows=&quot;9&quot; name=&quot;select&quot; cols=&quot;45&quot;></textarea>
<input type=&quot;reset&quot; value=&quot;Reset&quot; name=&quot;B2
    <!-- Second Textbox End -->

</td>
</form>

Currently when I choose the dropdown, my textboxes resets and won't passtext.
thanks for any solutions.
tav
 
i don't understand well what you want to do,
but you shouldn't use this :

<select name=&quot;select1&quot; onChange=&quot;document.myform.submit()&quot;>

it post the page on itself and you'll loose all your data

don't use the onchange event on your 'option' tag and try something like this :

<select name=&quot;select1&quot; onChange=&quot;passText(this)&quot;>
<option>Select one:</option>
<option value=&quot;&quot;>Workorder</option>
<option value=&quot;&quot;>Leadcraft</option>
</select>


function passText(SELECT)
{

document.myform.select.value = &quot;Where WORKORDER.LEADCRAFT in ('&quot;+ SELECT.option[SELECT.selectedIndex].text +&quot;')&quot;;

}
 
2ni,
Thanks for the quick reponse.
Adding your option change allowed the string to pass but when I changed the function per your change, it only passed the word OPTION and not what I had typed into the textbox.

The reason I'm trying to use the onchange event on each option is that I have about ten text strings I need to append to the text that gets passed after the user selects.
ie.
Where WORKORDER.WONUM in ('')
Where WORKORDER.LEADCRAFT in ('')
Where WORKORDER.EQNUM in ('')
Where WORKORDER.LOCATION in ('')
etc.

After the user types into the first textbox,
I was using two different buttons to run the function
passText
and
passText2

Now I want to just use a dropdown instead.
Here is an example of the program->
Go into Workorder, which is a frames page and type in a string of numbers, space, string of numbers and press the appropriate button. Try both buttons!

This application will build a SQL string when pasting a column of information from excel.

Thanks
tav
 
one more thing aint select a key word? why do u use it as a name for a field???

Known is handfull, Unknown is worldfull
 
vbkris,
Not sure where your talking about? or why it's like that?
Could give example?
tav
 
u have ur textfield name as select right?
<select> is a HTML tag, so JS may throw up errors, its better to avoid such errors...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top