473,772 Members | 2,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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"><op tion>....</option>....

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

I tried to replace ???? with:
document.getEle mentById['sel_id'].options[document.getEle mentById['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=docume nt.getElementBy Id['hidden'].value=this.opt ions[this.selectedIn dex].text"><option> ....</option>....
....
<a href="somefile. php&new=1&s=doc ument.getElemen tById['hidden'].value>

Mar 15 '06 #1
4 17035

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"><op tion>....</option>....

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

I tried to replace ???? with:
document.getEle mentById['sel_id'].options[document.getEle mentById['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="javascrip t:document.loca tion.assign('so mefile.php&new= 1&s=' +
document.getEle mentById('sel_i d').options[document.getEle mentById('sel_i d').selectedInd ex].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"><op tion>....</option>....

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

I tried to replace ???? with:
document.getEle mentById['sel_id'].options[document.getEle mentById['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="javascrip t:document.loca tion.assign('so mefile.php&new= 1&s=' +
document.getEle mentById('sel_i d').options[document.getEle mentById('sel_i d').selectedInd ex].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="docume nt.location.hre f=....;return
false">Link Text</a>

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

--
Randy
comp.lang.javas cript 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="docume nt.location.hre f=....;return
false">Link Text</a>

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

--
Randy
comp.lang.javas cript 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.locat ion.assign(..." is not worse then
"document.locat ion.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="docume nt.location.hre f=....;return
false">Link Text</a>

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

--
Randy
comp.lang.javas cript 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="someAnimat edGif.gif">
<a href="javascrip t: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.locat ion.assign(..." is not worse then
"document.locat ion.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.javas cript 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
9438
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 can I change display1 to value by reference if there is difference? void display(int &i){// Passing value by reference
2
3517
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 field value in a hyperlink as the value is always changing. Anyone have any suggestions?
25
2945
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 construction and then.. // some other processing and/or changing 'retval' return retval; }
4
3906
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 inserted in the database, to enable me then to reference that number at a later date. (The hidden value (1 for example) would then automatically get passed to the other input field.)
2
3635
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, ByVal price as double) AsName = sname AsPrice = price
2
1420
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 same thing in ASP.NET as: opening a form and passing a value to OpenArgs so that the next form can access that value? Also, for using a selected value from a DataGrid, could someone please show me the convention (and steps - please?) for...
1
1557
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"> <a href = "test.php?c1=document.getElementById('field1').value&c2=document.getElementById('field2').value ><img src="add.gif" border="0"></a>
5
13296
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 will increment/decrement the form field value by 1 when clicked. I'm using the following code, however when I click on one of the links, I get the following error -
12
2594
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 by value temporaries are created?(I'm not touching yet the cases where standard allows optimizations from the side of implementations to avoid copying) If so, please quote part of the standard that says that. Assuming it is true, I can imagine two...
6
4050
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 the database and posts these programs for people to view (program type, date, time, etc...). I am having trouble creating an edit option. When bring up the edit page i want it to read the database and dynamically create a table that has a button...
0
9621
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7461
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.