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

Form Submission: Final URL that has form options included ??

Hi there
I am trying to do the following with no luck:

I want to have a form with two select menus. Each menu will obvisouly
have different options, each with its own value. Then quite simply,
when the user clicks on the submit button, I want the resulting URL to
include options from the select fields ( ie: whatever the user has
selected.)

For eg: for a date URL, the final URL might be:

'http://www.comics.com/' +day+ '/' +month+ '/garfield.gif'

Hope this makes sense, and appreciate any assistance.
Thanks,
Jared
Jul 20 '05 #1
5 2648

"Jared" <ja**************@iqpc.co.uk> wrote in message
news:47**************************@posting.google.c om...
Hi there
I am trying to do the following with no luck:

I want to have a form with two select menus. Each menu will obvisouly
have different options, each with its own value. Then quite simply,
when the user clicks on the submit button, I want the resulting URL to
include options from the select fields ( ie: whatever the user has
selected.)

For eg: for a date URL, the final URL might be:

'http://www.comics.com/' +day+ '/' +month+ '/garfield.gif'

Hope this makes sense, and appreciate any assistance.
Thanks,
Jared


Well, I'm not one hundred what you mean, but maybe this is useful...

You could create hidden fields to hold the values of the options selected in
your select boxes, and change their values whenever an option is clicked,
like this:

<select name="selectBoxDay" id="selectBoxDay"
onChange="this.form.day=this.options[this.selectedIndex].value;">
//options
</select>
<select name="selectBoxMonth" id="selectBoxMonth"
onChange="this.form.month=this.options[this.selectedIndex].value;">
//options
</select>

<input name="day" type="hidden" value="">
<input name="month" type="hidden" value="">

- not sure if the onChange syntax is correct, since I haven't checked it ;)

Would this help?

Daniel

--
There are 10 kinds of people: Those who know binary and those who don't.
Jul 20 '05 #2
Does the url have to be in this format? If not then why don't you just use
method="get" in the form tag, this will display something like:-

'http://www.comics.com/nextpage.html?option1=one&option2=two&option3=thre e'

Then if you want to pull it out of the querystring on the backend with JS or
Serverside script it should be easier for you.

Hope that helps.

Stu

"Jared" <ja**************@iqpc.co.uk> wrote in message
news:47**************************@posting.google.c om...
Hi there
I am trying to do the following with no luck:

I want to have a form with two select menus. Each menu will obvisouly
have different options, each with its own value. Then quite simply,
when the user clicks on the submit button, I want the resulting URL to
include options from the select fields ( ie: whatever the user has
selected.)

For eg: for a date URL, the final URL might be:

'http://www.comics.com/' +day+ '/' +month+ '/garfield.gif'

Hope this makes sense, and appreciate any assistance.
Thanks,
Jared

Jul 20 '05 #3
This will generate the required URL pattern:

http://www.comics.com/04/05/page.htm

This will not submit the form however, so the destination page will not be
able to read any POST/GET form variables.

The call to the javascript can be placed in the form tag as an onSubmit
event, or on a button in the form as an onClick event.

<script type="text/javascript">
function ProcessForm(domain,page)
{
var formObject=document.forms['myform'];
var Select1Object=formObject.elements['select1'];
var Select1Object=formObject.elements['select2'];
var Select1Value=Select1Object.options[Select1Object.selectedIndex].value;
var Select2Value=Select2Object.options[Select2Object.selectedIndex].value;

if(Select1Value=='null')
{
return false;
}

if(Select2Value=='null')
{
return false;
}

window.location.href='http://'+domain'/'+Select1Value+'/'+Select2Value+'/'+p
age;
}
</script>

....

<form name="myform" action="#"
onSubmit="ProcessForm('www.comics.com','page.htm') ; return false;">
<select name="select1">
<option value="null">Select day</option>
<option value="01">1</option>
....
<option value="31">31</option>
</select>
<select name="select2">
<option value="null">Select month</option>
<option value="01">January</option>
....
<option value="12">December</option>
</select>
<input type="submit" value="Go">
<input type="button" value="Go"
onClick="ProcessForm('www.comics.com','page.htm'); return false;">
</form>

"Jared" <ja**************@iqpc.co.uk> wrote in message
news:47**************************@posting.google.c om...
Hi there
I am trying to do the following with no luck:

I want to have a form with two select menus. Each menu will obvisouly
have different options, each with its own value. Then quite simply,
when the user clicks on the submit button, I want the resulting URL to
include options from the select fields ( ie: whatever the user has
selected.)

For eg: for a date URL, the final URL might be:

'http://www.comics.com/' +day+ '/' +month+ '/garfield.gif'
Do you just want to generate the above URL pattern, or do you want to submit
the form variables (day, month) as well?

Hope this makes sense, and appreciate any assistance.
Thanks,
Jared

Jul 20 '05 #4
"Jared" <ja**************@iqpc.co.uk> schrieb im Newsbeitrag
news:47**************************@posting.google.c om...
Hi there
I am trying to do the following with no luck:

I want to have a form with two select menus. Each menu will obvisouly
have different options, each with its own value. Then quite simply,
when the user clicks on the submit button, I want the resulting URL to
include options from the select fields ( ie: whatever the user has
selected.)

For eg: for a date URL, the final URL might be:

'http://www.comics.com/' +day+ '/' +month+ '/garfield.gif'

Hope this makes sense, and appreciate any assistance.
Thanks,
Jared


You could try something like (not tested):

<form name="myform" action="" method="post"
onSubmit="document.myform.action='http://www.comics.com/' +
document.myform.day.value + '/' + document.myform.month.value +
'/garfield.gif'">

I am sorry I have no time to figure this out in detail; maybe you have to
make a onClick on the submit button instead of an onSubmit in the form tag.

You can also go another way:

<form name="myform" action="http://www.comics.com/garfield.htm"
method="get">

this loads an url with a query string:
http://www.comics.com/garfield.htm?d...onth=yourmonth

And you create a document garfield.htm with a script that parses the query
string and loads the appropriate gif.

hth
--
Markus
Jul 20 '05 #5
Thanks all for the help - using the different posts I have com up woth a solution.

Thanks again !
Jul 20 '05 #6

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

Similar topics

9
by: Tom | last post by:
I have created the following code for a product select/payment form (don't know if there is a better way) and I have been trying to make the following changes (unsuccessfully so far): 1) ...
19
by: Pete | last post by:
I have form/select which executes a function using onchange. No problem. However, when I validate the page with a strict HTML 4.01 doctype at http://validator.w3.org, it demands either an action or...
3
by: John Dunlop | last post by:
(Note crosspost and follow-ups to ciwah.) Nicolas Keller wrote in thread "Differences in form handling btw Mozilla and IE?": > The problem: I'm using a form that submit's (POST) its data via...
16
by: lawrence | last post by:
I was told in another newsgroup (about XML, I was wondering how to control user input) that most modern browsers empower the designer to cast the user created input to a particular character...
0
by: Piotr Nienaltowski | last post by:
!!! DEADLINE FOR PAPER SUBMISSIONS HAS BEEN EXTENDED UNTIL FEBRUARY 26, 2004 !!! ---------------------------------------------------------------- .NET TECHNOLOGIES 2004 2nd International...
4
by: mparisi | last post by:
I have a responsibility within my testing department to automate the submission of data on 4 sequential asp pages. Here's the tasks: 1. Sign in 2. Enter form data and submit 3. Enter more...
6
by: brettev | last post by:
World, I work at a university where the professors have a system to input grades for assignments and calculate final grades, which is output to an excel file. they are then required to get on a...
4
by: JLupear | last post by:
My friend and I are trying to start a business and are writing a website of our own. We have been trying to create an online estimator and are having trouble with writing the javascript that is to...
1
by: hotrod57 | last post by:
I am trying to append the results from a form to a text file. My code is supposed to print out the results on one page, and append the results to another page each time data is entered on the form...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.