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

passing a field value in href

Hi all,
I am trying to pass a value of a field as an argument to href but I am
not doing it right:

<select name="sel_name" id="sel_id"><option>....</option>....

<a href="somefile.php?new=1&s=?????>text</a>

I tried to replace ???? with:
document.getElementById['sel_id'].options[document.getElementById['sel_id'].selectedIndex].text

didn't work.

I tried to set a hidden field's value when selection changed and use
that value for ???? but that didn't work either.

<select name="sel_name" id="sel_id"
onChange=document.getElementById['hidden'].value=this.options[this.selectedIndex].text"><option>....</option>....
....
<a href="somefile.php&new=1&s=document.getElementById['hidden'].value>

Mar 15 '06 #1
4 17024

Xerxes wrote:
Hi all,
I am trying to pass a value of a field as an argument to href but I am
not doing it right:

<select name="sel_name" id="sel_id"><option>....</option>....

<a href="somefile.php?new=1&s=?????>text</a>

I tried to replace ???? with:
document.getElementById['sel_id'].options[document.getElementById['sel_id'].selectedIndex].text

didn't work.

I tried to set a hidden field's value when selection changed and use
that value for ???? but that didn't work either.

<a href="javascript:document.location.assign('somefil e.php&new=1&s=' +
document.getElementById('sel_id').options[document.getElementById('sel_id').selectedIndex].text);">Link</a>

Mar 16 '06 #2
marss said the following on 3/16/2006 2:02 AM:
Xerxes wrote:
Hi all,
I am trying to pass a value of a field as an argument to href but I am
not doing it right:

<select name="sel_name" id="sel_id"><option>....</option>....

<a href="somefile.php?new=1&s=?????>text</a>

I tried to replace ???? with:
document.getElementById['sel_id'].options[document.getElementById['sel_id'].selectedIndex].text

didn't work.

I tried to set a hidden field's value when selection changed and use
that value for ???? but that didn't work either.

<a href="javascript:document.location.assign('somefil e.php&new=1&s=' +
document.getElementById('sel_id').options[document.getElementById('sel_id').selectedIndex].text);">Link</a>


Before posting here, endeavor yourself and take the time to read this
groups FAQ. Especially http://jibbering.com/faq/#FAQ4_24

<a href="noscript.html" onclick="document.location.href=....;return
false">Link Text</a>

And then, you won't be propagating bad habits.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 16 '06 #3

Randy Webb wrote:
Before posting here, endeavor yourself and take the time to read this
groups FAQ. Especially http://jibbering.com/faq/#FAQ4_24

<a href="noscript.html" onclick="document.location.href=....;return
false">Link Text</a>

And then, you won't be propagating bad habits.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


1.I carefully read faq 4.24 and I am not sure that my code so terrible.

The ideas that are stated there is pure theory, I was acquainted with
them before.
Number of people that use browsers with unsupported or disabled scripts
too small.
The most of software are made with the expectation of normal users
rather than few retrogrades.
2.Problem with browsers which do not understand javascript, or have it
disabled,
should be resolved at the whole page level rather then for each link
separately.
3.This task does not have decision without using javascript.
Therefore "document.location.assign(..." is not worse then
"document.location.href=....".

Sorry for my English.

Mar 16 '06 #4
marss said the following on 3/16/2006 8:56 AM:
Randy Webb wrote:
Before posting here, endeavor yourself and take the time to read this
groups FAQ. Especially http://jibbering.com/faq/#FAQ4_24

<a href="noscript.html" onclick="document.location.href=....;return
false">Link Text</a>

And then, you won't be propagating bad habits.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
1.I carefully read faq 4.24 and I am not sure that my code so terrible.


It is. You did not bother to understand it is all. And maybe read the
Notes page on it. It has a very serious drawback to it.
The ideas that are stated there is pure theory, I was acquainted with
them before.
They are not "pure theory" the problem with a javascript: URL is very
well known.
Number of people that use browsers with unsupported or disabled scripts
too small.
The most of software are made with the expectation of normal users
rather than few retrogrades.
That is not the only problem with it.

<img src="someAnimatedGif.gif">
<a href="javascript:alert('Watch the animated Gif')">Test it</a>

Run that through IE and get back to me.
2.Problem with browsers which do not understand javascript, or have it
disabled, should be resolved at the whole page level rather then for
each link separately.
Absolutely. And part of doing that is not making your links JS
dependent. Then you have nothing else to worry about.
3.This task does not have decision without using javascript.
Therefore "document.location.assign(..." is not worse then
"document.location.href=....".


My comments had nothing to do with assign versus href. It had to do,
directly, with the use of the javascript: pseudo-protocol.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 18 '06 #5

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

Similar topics

3
by: sam pal | last post by:
I have the following programs and please clear my doubts. Passing the value by reference is same as pointer by reference. Is this true? What is the difference between display and display2? How...
2
by: Patrick | last post by:
I currently us JavaScript to populate a hidden field with my scroll location in order to retain the page location when I post the page back to itself. However, I don't know how to pass that hidden...
25
by: Victor Bazarov | last post by:
In the project I'm maintaining I've seen two distinct techniques used for returning an object from a function. One is AType function(AType const& arg) { AType retval(arg); // or default...
4
by: GavMc | last post by:
Hello I am new to internet programming and wonder if anyone can help me with this.... I am trying to pass a hidden field value on a form into another field on the form so that it can then be...
2
by: o1j2m3 | last post by:
I created 2 forms, A and B using VB.NET 2003 in A, the codes are : ========================== public AsName as string public AsPrice as double public sub setValue(ByVal sname as string,...
2
by: jonefer | last post by:
I'm using a Public variable that I set on one page so that it will be available for another page but, I know this isn't the way it should be done. Being an Access Developer, how would I do the...
1
by: Xerxes | last post by:
Hi, I am trying to pass the value of a field to a PHP file like this: <input type="hidden" name="field1" id="field1" value="123"> <input type="hidden" name="field2" id="field2" value="456"> ...
5
by: Stuart | last post by:
Hi all, Iv'e got a page that has a mass amount of input fields, all of which require a decimal figure. To make it easier when it comes to inputting data, I'm trying to setup + and - links that...
12
by: dave_dp | last post by:
Hi, I have just started learning C++ language.. I've read much even tried to understand the way standard says but still can't get the grasp of that concept. When parameters are passed/returned...
6
by: djjohnst | last post by:
I am creating a program that will list program times for people who visit our website. Users can login create, edit, delete a program. These dump into a database. The ASP webpage then reads from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.