Hi,
in my SELECT (like below), the option value has 2 values, separated with
comma ","
<select name="sIdName">
<option value="10,John" >John</option>
<option value="11,Eva"> Eva</option>
<option value="22,Danny ">Danny</option>
</select>
How can I read these two values individually from Javascript statement ?
like one is 10, another one is John
i.e document.form.o ption[document.form.s electedIndex].value ?
thanks. 4 10341
"magix" <ma***@asia.com wrote in message
news:45******** **@news.tm.net. my...
Hi,
in my SELECT (like below), the option value has 2 values, separated with
comma ","
<select name="sIdName">
<option value="10,John" >John</option>
<option value="11,Eva"> Eva</option>
<option value="22,Danny ">Danny</option>
</select>
How can I read these two values individually from Javascript statement ?
like one is 10, another one is John
i.e document.form.o ption[document.form.s electedIndex].value ?
thanks.
and also how can I use document.getEle mentById('sIdna me').value to retrieve
10 and John? (Assume <Select name="sIdName" id="sIdName"..> , some sort of
split function need to be done.
magix said the following on 3/17/2007 5:28 AM:
Hi,
in my SELECT (like below), the option value has 2 values, separated with
comma ","
No, it has one value that contains a comma.
<select name="sIdName">
<option value="10,John" >John</option>
<option value="11,Eva"> Eva</option>
<option value="22,Danny ">Danny</option>
</select>
How can I read these two values individually from Javascript statement ?
like one is 10, another one is John
i.e document.form.o ption[document.form.s electedIndex].value ?
var selectValue = document.forms['formName'].elements['selectName'].value
var theArray = selectValue.spl it(',')
var firstValue = theArray[0]
var secondValue = theArray[1]
--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
magix wrote on 17 mrt 2007 in comp.lang.javas cript:
Hi,
in my SELECT (like below), the option value has 2 values, separated
with comma ","
<select name="sIdName">
<option value="10,John" >John</option>
<option value="11,Eva"> Eva</option>
<option value="22,Danny ">Danny</option>
</select>
How can I read these two values individually from Javascript statement
? like one is 10, another one is John
i.e document.form.o ption[document.form.s electedIndex].value ?
It pays to read the specs:
selectedIndex is no child of form but of the select.
form is not the same as forms[0].
use:
=============== =============
<form>
<select name="sIdName">
<option value="10,John" >John</option>
<option value="11,Eva" selected>Eva</option>
<option value="22,Danny ">Danny</option>
</select>
</form>
<script type='text/javascript'>
var r = document.forms[0].elements['sIdName']
var rr = r.options[r.selectedIndex].value.split(', ');
alert(rr[0]); // 11
alert(rr[1]); // Eva
</script>
=============== =============
or:
=============== =============
<select name="sIdName" onchange='chd(t his)'>
<option value="--,--">-- ? --</option>
<option value="10,John" >John</option>
<option value="11,Eva"> Eva</option>
<option value="22,Danny ">Danny</option>
</select>
<script type='text/javascript'>
function chd(r) {
if (r.selectedInde x==0) return;
var rr = r.options[r.selectedIndex].value.split(', ');
alert(rr[0]);
alert(rr[1]);
};
</script>
=============== =============
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
"Randy Webb" <Hi************ @aol.comwrote in message
news:DN******** ************@gi ganews.com...
magix said the following on 3/17/2007 5:28 AM:
>Hi,
in my SELECT (like below), the option value has 2 values, separated with comma ","
No, it has one value that contains a comma.
> <select name="sIdName"> <option value="10,John" >John</option> <option value="11,Eva"> Eva</option> <option value="22,Danny ">Danny</option> </select>
How can I read these two values individually from Javascript statement ? like one is 10, another one is John
i.e document.form.o ption[document.form.s electedIndex].value ?
var selectValue = document.forms['formName'].elements['selectName'].value
var theArray = selectValue.spl it(',')
var firstValue = theArray[0]
var secondValue = theArray[1]
--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Thank you. Case Closed. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michael Hoffmann |
last post by:
Hello,
As you might guess I am completely new to this language. Maybe I get some
help here.
I try to execute a user defined funciton from a select option in a document
to read a file
into an array without using a submit button or anything else.
like this:
<select name="sel" onchange="<?php ReadFile(DependingOnValue);<?" >
<option value="1"> 1st Quarter </option>
<option value="2"> 2nd Quarter </option>
|
by: J. Muenchbourg |
last post by:
I have an ASP admin script where I'm adding records, and I have a
category that already has set name values hard-coded into a selct option
pulldown, but if the user wants to create a new category and not use the
select pulldown, the value will end up being " , newvalue" when posting
from this sequence of pulldown and input text box:
<select name="CategoryName">
<option selected></option>
<option value="first">first category</option>...
|
by: Robert Kattke |
last post by:
I'm designing a site for local music and entertertainment and have a
few ?s that need to be cleared up. Currently, I'm working on the Club
part and have a Contact Person form, and a Club form. For the Club
form, I'd like to have up to 4 Contacts with various roles, {Booking,
Manager, Owner, All}.
Ideally, I'd like to have a frameset and have Contact form filled out
1st, allowing me to set a cookie that would populate the...
|
by: Old Lady |
last post by:
Hi,
I need help!
I have a SELECT/OPTION list.
My goal is to have a TEXT input field in a form that is normally
disabled, but it should become enabled when the user select one
predefined OPTION. If the user change idea and select another OPTION,
the TEXT input field should be disabled again.
I hope I'm understandable.
Sorry for my bad English.
|
by: Chris Fink |
last post by:
Does anyone know it is possible to include a small image(.gif .jpeg)
within a <SELECT><option> so that the user would see the option text as
well as a little image(icon) in the option? I know this is not an ASP.NET
related question, but I know this group is knowledgeable and quick with
responses.
Thanks
| |
by: kirke |
last post by:
I want to load textarea's value in drop-down box.
In first page, such form is existed.
<form name="form1" method="post" action="next.php">
<textarea name="dayList" Id = "dayList" cols=20
rows=10></textarea>
</form>
in text area there's one column of values.
|
by: ajay2552 |
last post by:
Hi,
I have a query.
All html tags start with < and end with >. Suppose i want to display either '<' or '>' or say some text like '<Company>' in html how do i do it?
One method is to use <, > ,<Company> to display '<', '>' and '<Company>' respectively.
But is there any freeware code available which could implement the above functionality without having to use >,< and such stuff???
|
by: The Natural Philosopher |
last post by:
This is a nasty one and I can't see my way out of it.
I have a bunch of select statements in a form, and each select statement
has an onchange="do_something(this)" in it, and this works
nicely..except when there is only ONE OPTION in a given select.
It seems you cannot 'onchange' a single option!
Well, that is reasonable.
The trouble is I have no way of selecting it since the form itself is a
|
by: pravinnweb |
last post by:
Hi i have select option in my page which works fine in firefox in which i mention specific width for select option when i clicked select list the option lengths are large the option area is expanded on firefox but in IE the option area is not expanded but when i removed the width then it works fine in IE but the select list width also incresed i dont want to expand the width of select tab here is the code
<tr><td >
<select...
|
by: fsalvador |
last post by:
Hi,
I am trying to figure it out how to to hide in onmouseout the select options of a form. Below is the code I got so far. It isn't working.
Please help.
Thanks
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
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,...
| |
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...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |