Click to See Complete Forum and Search --> : Manipulating Form String


Bruno
03-18-2003, 08:54 AM
Hi All

Wondering if anyone can help or point to where I am going wrong.

I am trying to take a user submitted value from a search form (OriginalQuery), add text to it, then continue to submit the form with the updated OriginalQuery.

To do this I have created a function (SortTextOut()) that concatenates the OriginalQuery with a string and then updates OriginalQuery before submitting the form.

<script language=JavaScript>
<!--//
var UserInput
function SortTextOut() {
UserInput = "@all " + OriginalQuery + " AND NOT #filename *.doc AND NOT #filename *.xls AND NOT #filename *.css AND NOT #filename *.ppt AND NOT #filename *.dwg AND NOT #filename *.vsd AND NOT #filename *.txt AND NOT #filename *.tmp AND NOT #filename *.pdf"
OriginalQuery = UserInput
}
//-->
</script>
</head>
<body>
<form name=QueryForm action="query4.idq" method="GET">
<input type="text" name="OriginalQuery" size="10" maxlength="50" value="" OnSubmit="SortTextOut()">
</form>


As you can see I have tried...but ultimately failed - if anyone can help it would be greatly appeciated.

Thanks Loads

Bruno

gil davis
03-18-2003, 09:17 AM
All things being equal (I did not fully examine your strings), changeUserInput = "@all " + OriginalQuery + "..."
OriginalQuery = UserInput to: UserInput = "@all " + document.QueryForm.OriginalQuery.value + "..."
document.QueryForm.OriginalQuery.value = UserInput

Bruno
03-18-2003, 09:39 AM
Hi Gil

Thanks for replying;

I have tried the code you gave me but it didn't work. However... I have modified it and stumbled onto the answer.

<script language=JavaScript>
<!--//
function SortTextOut( elem )
{
elem.value = "@all " + elem.value + " AND NOT #filename *.doc AND NOT #filename *.xls AND NOT #filename *.css AND NOT #filename *.ppt AND NOT #filename *.dwg AND NOT #filename *.vsd AND NOT #filename *.txt AND NOT #filename *.tmp AND NOT #filename *.pdf";
}
//-->
</script>
</head>
<body>

<form name="QueryForm" action="query4.idq" method="GET" onsubmit="SortTextOut( this.OriginalQuery )">
<input type="text" name="OriginalQuery" size="15" maxlength="50" value="">
</form>



:) Thanks Gil - your code certainly led me to the answer I needed.

Bruno :cool: